我坚持看似初学者的编译错误:
我的简单程序:
#include <stdlib.h>
#include <stdio.h>
#include "Tiles_Circular_Linked_List.h"
#define MAX_LINE_LENGTH 128;
int main(int argc, char **argv) {
struct node *head_tail;
FILE *file;
/*char filename[] = "/home/student/Desktop/Studies/C/testing_fodder/tiles";*/
argv++; /*go to second character-array argument*/
file = fopen(*argv, "r");
char *curr_line;
fgets(curr_line, MAX_LINE_LENGTH, file);
return 0;
}
我尝试使用此命令编译它:
gcc -g -Wall -ansi launch_tiles.c -o tiles_prog
并得到这些错误:
launch_tiles.c:在函数'main'中:launch_tiles.c:17:19:error:expected')'before';'token launch_tiles.c:17:19:error:函数'fgets'/ usr的参数太少/include/stdio.h:628:14:注意:在这里声明launch_tiles.c:9:8:警告:变量'file'设置但未使用[-Wunused-but-set-variable] launch_tiles.c:8:15 :警告:未使用的变量'head_tail'[-Wunused-variable]
我对错误感兴趣,而不是警告 .
我可以算上三个论点,我传给了 fgets
并且问题是什么?
谢谢!
1 回答
更改
至
(没有
;
) . 容易犯错误 .C预处理器执行非常简单的文本替换,因此使用错误定义的宏,您最终会得到
这显然是语法错误 .