怎么编译后运行错误!!

来源:百度知道 编辑:UC知道 时间:2024/06/29 01:06:49
把200个字符写入一个文本 怎么不能运行呢 !!郁闷死了 怎么看都没错啊 我用的是TU2.0
#include "stdio.h"
main()
{ FILE *fp;
int i;
char c;
if((fp=fopen("C:\Documents and Settings\Administrator\My Documents\f1.txt","w"))==NULL)
{ printf("file can not open !\n");
exit(0);
}
for(i=0;i<200;i++)
{ c=getchar();
fputc(c,fp);
}
fclose(fp);
getch();
}

if((fp=fopen("C:\Documents and Settings\Administrator\My Documents\f1.txt","w"))==NULL)改为:
if((fp=fopen("C:\\Documents and Settings\\Administrator\\My Documents\\f1.txt","w"))==NULL)
字符串\后跟的是一个占位符~~~无论哪儿要存储\必须用转义序列.