关于C语言文件读取fopen函数的问题

Tony_cheer Tony_cheer 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
刚入门学习C语言,用VS2012平台,使用fopen函数时报错:
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main(void)
{
FILE * fp;
if (fopen_s(&fp,"C:\\Users\\Administrator\\Desktop\\EGM96","r")!=0)
{
printf("The file open error!\n");
exit(0);
}
int a;
a=fclose(fp);
return 0;
}


设断点逐步运行时,出现报错:
>c:\users\administrator\desktop\test\test\test.c(14): error C2143: 语法错误 : 缺少“;”(在“类型”的前面)
int main(void)
{
FILE * fp;
/*if (fopen_s(&fp,"C:\\Users\\Administrator\\Desktop\\EGM96","r")!=0)
{
printf("The file open error!\n");
exit(0);
}*/
int a;
//a=fclose(fp);
return 0;
}

这样就能运行了,求解答,谢谢!
另外,VS配置了opencv 不知是不是受这个影响
...全文
评论 9
收藏 已收藏
分享
返回顶部
Tony_cheer
C语言 70,040 成员 243,237 内容