Amoiensis / Matrix_hub

A lib of Matrix operation for C language. (矩阵运算库--C语言)
Apache License 2.0
234 stars 53 forks source link

[help]函数最后没有返回值 #17

Open sjhsbhqf opened 10 months ago

sjhsbhqf commented 10 months ago

源代码:


int help(char *file_name) {/*
 * Help.
 * 可以调用如, help("help"),查看help函数的使用方法和内容*/
    printf(">>HELP(");
    printf(file_name);
    printf(")\n");
    char temp_route[_MAX_HELP_LENGTH_] = "../help/";
    char temp_txt[5] = ".txt";
    strcat(temp_route, file_name);
    strcat(temp_route, temp_txt);
    FILE *fp;
    char ch;
    fp = fopen(temp_route, "r");
    if (fp == NULL) {
        printf(temp_route);
        printf(" can not open!\n");
    } else {
        fscanf(fp, "%c", &ch);
        while (!feof(fp)) {
            putchar(ch);
            fscanf(fp, "%c", &ch);
        }
        fclose(fp);
    }
    printf("\n");
}

修正代码:

int help(char *file_name) {/*
 * Help.
 * 可以调用如, help("help"),查看help函数的使用方法和内容*/
    printf(">>HELP(");
    printf(file_name);
    printf(")\n");
    char temp_route[_MAX_HELP_LENGTH_] = "../help/";
    char temp_txt[5] = ".txt";
    strcat(temp_route, file_name);
    strcat(temp_route, temp_txt);
    FILE *fp;
    char ch;
    fp = fopen(temp_route, "r");
    if (fp == NULL) {
        printf(temp_route);
        printf(" can not open!\n");
    } else {
        fscanf(fp, "%c", &ch);
        while (!feof(fp)) {
            putchar(ch);
            fscanf(fp, "%c", &ch);
        }
        fclose(fp);
    }
    printf("\n");
    return 0;
}