【发布时间】:2009-03-04 06:31:45
【问题描述】:
#include <stdio.h>
main(void) {
file *file = fopen("words.txt","r")
if(file != null) {
char line[128];
while(fgets( line, sizeof line, file) != null)
{
fputs ( line, stdout );
}
fclose ( file );
}
}
这是我的代码。我试图读取文件并输出内容。 但这给了我错误代码
main.c: In function 'main':
main.c:4: error: 'file' undeclared (first use in this function)
main.c:4: error: (Each undeclared identifier is reported only once
main.c:4: error: for each function it appears in.)
main.c:5: error: parse error before "if"
main.c:7: error: 'line' undeclared (first use in this function)
main.c:7: error: 'null' undeclared (first use in this function)
main.c: At top level:
main.c:13: error: parse error before '}' token
main.c:13:2 warning: no newline at end of file
我该如何解决这个错误。
【问题讨论】:
标签: c