比如
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(void)
{
char pathname[10];
printf("input the file name: ");
scanf("%s",pathname);
strcat(pathname,".in");
FILE *fp;
fp = fopen( pathname , "r+" );
if( fp == NULL )
{
printf(" can not open file !!\n");
return 0;
}
printf("opened!\n\n\n");
fclose(fp);
printf("closed!\n\n\n");
return 0;
}
在gcc上就能正常的编译,结果如所料一样。
而在vc++上就会出现这样的错误提示:
e:\source\exp1.c(19) : error C2275: 'FILE' : illegal use of this type as an expression
e:\program files\microsoft visual studio\vc98\include\stdio.h(156) : see declaration of 'FILE'
e:\source\exp1.c(19) : error C2065: 'fp' : undeclared identifier
有没有告诉我为什么会这样?怎么解决?