文件追加

#include <stdio.h>

int main()
{
	FILE *fpSrc=NULL;
	FILE *fpDst=NULL;
	//char ch;
	char srcFilename[20]="src.txt";
	char dstFilename[20]="dst.txt";
	if ((fpSrc=fopen(srcFilename,"r"))==NULL)
	{
		printf("Can't open the source file!\n");
		exit(0);
	}
	if ((fpDst=fopen(dstFilename,"a"))==NULL)
	{
		printf("Can't open the destination file !\n");
		exit(0);
	}
	while(!feof(fpSrc))
	{
		fputc(fgetc(fpSrc),fpDst);
	}
	fflush(fpDst); 
	if (fpSrc!=NULL)
	{
		fclose(fpSrc);
	}
	if (fpDst!=NULL)
	{
		fclose(fpDst);
	}
        return 0;
} 

文件 追加
您的回应...

相关话题

查看全部

也许你感兴趣

换一批

热门标签

更多