简单代码如下:下面的例子是将file.txt里的内容追加到files.txt 中:
FILE *fp; FILE *file; char character; if((fp=fopen("file.txt","r"))==NULL) { printf("Cac't open the file!\n"); exit(1); } if((file=fopen("files.txt","a+"))==NULL) { printf("Cac't open the file!\n"); exit(1); } while((character=getc(fp))!=EOF) fwrite(&character,sizeof(char),1,file); //以追加方式写入; fclose(fp); fclose(file);