当我调用这个函数时
4 char *file_reader(FILE *fp, char *file_name, const char *mode) {
5 char *buffer;
6 fp = fopen(file_name, mode);
7
8 if (fp != NULL) {
9 fseek(fp, 0L, SEEK_END);
10 long s = ftell(fp);
11 rewind(fp);
12 buffer = malloc(s);
13 if (buffer != NULL) {
14 fread(buffer, s, 1, fp);
15 fclose(fp);
16 fp = NULL;
17 }
18 if (fp != NULL)
19 fclose(fp);
20 } else {
21 printf("No such file.\n");
22 return "ERR";
23 }
24 return buffer;
25 }
经过
char *file_content = file_reader(fp, input_file, "r");
gcc 一直在抱怨return from incompatible pointer type [enabled by default]
,但我没有看到任何不兼容的指针类型。任何人对此有任何想法,谢谢。