#include<iostream>
using namespace std;int main(){
FILE *txt_file1 = fopen("text1.txt","r");
FILE *txt_file2 = fopen("text2.txt","r");
FILE *txt_file3 = fopen("text3.txt","r");
FILE *txt_file4 = fopen("text4.txt","r");
FILE *txt_file5 = fopen("text5.txt","w+");
char ch=' ';
char ch1='\n';
while((fread(&ch,1,sizeof(char),txt_file1) )){
fwrite(&ch,1,1,txt_file5);
}
fwrite(&ch1,1,1,txt_file5); while((fread(&ch,1,sizeof(char),txt_file2) )){
fwrite(&ch,1,1,txt_file5);
}
fwrite(&ch1,1,1,txt_file5); while((fread(&ch,1,sizeof(char),txt_file3) )){
fwrite(&ch,1,1,txt_file5);
}
fwrite(&ch1,1,1,txt_file5); while((fread(&ch,1,sizeof(char),txt_file4) )){
fwrite(&ch,1,1,txt_file5);
}
fwrite(&ch1,1,1,txt_file5);
return 0;
}可以这样简单的写
c++ qt 合并多个txt文件
最新推荐文章于 2024-08-21 18:16:36 发布