Matrix_hub
Matrix_hub copied to clipboard
[help]函数最后没有返回值
源代码:
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;
}