小编tau*_*man的帖子

在C++中逐行复制

我试图将2个文件复制到1个文件,如ID1.name1.ID2.name2.但我不能这样做......我应该如何从每个文件中复制每一行.

#include <iostream>
#include <fstream>
using namespace std;
int main()
{

 ifstream file1("ID.txt");
   ifstream file2("fullname.txt");
   ofstream file4("test.txt");
   string x,y;
  while (file1 >> x )
   {
       file4 <<  x <<" . ";
       while (file2 >> y)
       {
           file4 << y <<" . "<< endl;
       }
   } 


}
Run Code Online (Sandbox Code Playgroud)

c++ copy file

1
推荐指数
1
解决办法
2116
查看次数

标签 统计

c++ ×1

copy ×1

file ×1