为什么返回的是no?除了什么问题
#include
int main()
{
FILE *fp;
fp=fopen("C:\Users\Administrator\Desktop\新建文本文档.txt","r+w");
if(fp==NULL)printf("no");
return 0;
}
可以尝试:
1.将文件路径中的单反斜杠换成双反斜杠,如:
fopen("C:\Users\Administrator\Desktop\新建文本文档.txt","r+w");
2.将文件路径中的单反斜杠换成斜杠,如:
fopen("C:/Users/Administrator/Desktop/新建文本文档.txt","r+w");
3.读fopen函数文档,看看什么时候返回NULL, 同时注意第二个参数滴写法
应该是
fp=fopen("C:\Users\Administrator\Desktop\新建文本文档.txt","r+w");
你木有加后缀名哦
新建文本文档.后面加了txt也是不行
你把第二个参数换个别的试下
应该是中文字符的问题,你把文件名重新命名一下应该就能成功了。如 123.txt
fopen第一个参数中的所有单反斜杠换成双反斜杠
fopen("C:\\Users\\Administrator\\Desktop\\新建文本文档.txt","r+w");