新手来的,关于打开文件的
#include "stdio.h " #include "stdlib.h "
void main()
{
FILE *fp;
fp = fopen( "ab.txt ", "r ");
if (!fp)
{
printf ( "error! ");
exit(1);
}
while (!feof(fp))
{
printf ( "%c ",fgetc(fp));
}
fclose(fp);
}
出现的错误有
D:\我的文档\C语言\P58 4.6.c(6) : error C2065: 'FILE' : undeclared identifier
D:\我的文档\C语言\P58 4.6.c(6) : error C2065: 'fp' : undeclared identifier
D:\我的文档\C语言\P58 4.6.c(6) : warning C4552: '*' : operator has no effect; expected operator with side-effect
D:\我的文档\C语言\P58 4.6.c(7) : warning C4013: 'fopen' undefined; assuming extern returning int
D:\我的文档\C语言\P58 4.6.c(10) : warning C4013: 'printf' undefined; assuming extern returning int
D:\我的文档\C语言\P58 4.6.c(13) : warning C4013: 'feof' undefined; assuming extern returning int
D:\我的文档\C语言\P58 4.6.c(15) : warning C4013: 'fgetc' undefined; assuming extern returning int
D:\我的文档\C语言\P58 4.6.c(17) : warning C4013: 'fclose' undefined; assuming extern returning int
执行 cl.exe 时出错.
P58 4.6.exe - 1 error(s), 0 warning(s)