Read and Write file (merge lines)

I am given a text file named tr4_1.txt, the file content is below:
1110000000001111
1110100000000000
1000001111111111
0111011101010101

I would like to ask how could I edit my code below so that the output file can combine all lines into one?
1110000000001111111010000000000010000011111111110111011101010101


#include <iostream>
#include <fstream>
#include <string>
#include <cstring>
using namespace std;

int main(void)
{
char ip_file[32]= "tr4_1.txt";
char opfile[32]="prefix.txt";
string line;
ofstream ofs; ofs.open(opfile);

ifstream ifs;
ifs.open(ip_file);

while(ifs.good()){
getline(ifs,line);

ofs<<line<<endl;


}



}
Last edited on
Please don't duplicate post, it's ultimately a time waster - you won't get more replies because of it.

http://www.cplusplus.com/forum/beginner/179793/
Don't write a line break if you want it in one line.

ofs<<line<<endl;
Topic archived. No new replies allowed.