#include<stdio.h>
int main()
{
FILE *fp;
char ch;
fp=fopen("D://TEST//text.txt","rt+");
if(fp==NULL)
{
printf("Open file fail!/n");
getch();
return 0;
}
/***************
printf("input your char: ");
ch=getchar(); //获取字符
while(ch !='/n')
{
fputc(ch,fp); //写入文件
ch=getchar();
if(ch=='/n')
{
break;
}
}
***************/
printf("output your file: ");
ch=fgetc(fp); //读文件内容
while(ch !=EOF)
{
putchar(ch); //显示文件内容
ch=fgetc(fp);
}
fclose(fp);
getch();
return 0;
}