实例1:读写字符文件,每次读取一个字符。
#include<stdio.h>
#include <stdlib.h>
int main()
{
FILE *fpin ;
FILE *fpout;
char c;
fpout=fopen("c:\\dest.txt","wt");
if((fpin=fopen("c:\\test.txt","rt"))!=NULL)
{
c = fgetc(fpin);
while(c!=EOF)
{
fputc(c,fpout);
c=fgetc(fpin);
}
}
else
{
printf("file not exist!");
exit(1);
}
fclose(fpin);
fclose(fpout);
return 0;
}