谁过来说一下如何读写文件。
这是我写的代码,说一下为什么,不能正确的读出来我录入的信息。还有怎么才能让这个程序每次运行都不删除次录入信息,谢谢
#include<stdio.h>
main()
{
int year,month,day;
char note;
FILE*fp;
fp=fopen;
if((fp=fopen("d:\\notebook.txt","w"))==NULL)
{puts("This file can not be opened");exit(0);}
fscanf(stdin,"%d%d%d%s",year,month,day,¬e);
fprintf(fp,"%d%d%d%s",year,month,day,note);
fclose(fp);
if((fp=fopen("d:\\notebook.txt","r"))==NULL)
{gets("This input file can not be opened");exit(0);}
fscanf(fp,"%d%d%d%ls",year,month,day,¬e);
fprintf(stdout,"%d %d %d %s",year,month,day,note);
fclose(fp);
getch();
}