91学习

陪伴你每一天!

将两个文件内容输入到同一个文件中

#include <stdio.h>

#include <process.h>


void main(){

FILE *fp1,*fp2;

char ch,filename1[30],filename2[30];

printf("请输入文件名1:\n");

scanf("%s",filename1);

printf("请输入文件名2:\n");

scanf("%s",filename2);

if((fp1=fopen(filename1,"ab+"))==NULL){

printf("can not open filename1:\n press any key to continue:\n");

getchar();

exit(0);

}

if((fp2=fopen(filename2,"rb"))==NULL){

printf("can not open file:\n press any key to continue:\n");

getchar();

exit(0);

}

fseek(fp1,0L,2);

while((ch=fgetc(fp2))!=EOF){

fputc(ch,fp1);

}

fclose(fp1);

fclose(fp2);

}

加威信18790284560免费送POS机.jpg

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。