VC编译器下c语言没有办法打开TXT文件。代码如下:#include
#include
void main()
{ FILE *fp;
if((fp=fopen("C:\Users\Administrator\Desktop\ad.txt","r"))==NULL)
{
printf("cannot open the file!");
exit(0);
}
else
printf("ok");
fclose(fp);
}
看errno的值
路径对吗
把路径改为这样试试:"C:\Users\Administrator\Desktop\ad.txt"
把路径改为这样试试:"C:/Users/Administrator/Desktop/ad.txt"
在字符串中\是表示转义,想要用\就要打两个\。
斜杆错了,应该写成\,可以参考转意字符表