#include <stdio.h>
#include <conio.h>
main()
{ FILE * fp;
char ch,filename[20]="E:\\mywork.txt";
/* **********************打开文件************************************* */
if(fp=fopen(filename,"w+")==NULL)
{printf("Can not open the file !!!!!!\n\n\n");
getch();
exit(0);
}
else printf("File open OK!!!!!!!!\n\n\n\n");
/* ************************向文件输入内容***************************** */
printf("Input the characters to the file:\n\n\n\n\n");
while((ch=getch())!='\r')
{ fputc(ch,fp);
putchar(ch);
}
/* ***********************关闭文件************************************ */
if(fclose(fp)==0)
printf("\n\n close ok!!!!!!\n\n\n\n");
else
printf("\n\n colse error!!!!!!!!!!!!!!!\n\n\n");
getch(); /* 请不要删除此行 */
}
这段程序在执行时总是关闭文件失败。麻烦大家帮我找一下错误
多谢了!!!