I have like this in a file1.txt I have like this in a file2.txt
OK Green > start 1 OK Green > start 1
OK Green > start 2 No Green > start 2
No Green > start 3 No Green > start 3
OK orange > start 1 No orange > start 1
No orange > start 2 OK orange > start 2
No orange > start 3 No orange > start 3
OK red > start 1 OK red > start 1
OK red > start 2 OK red > start 2
OK red > start 3 No red > start 3
Imagine I send the file1.txt from pc1 to pc2 where pc2 keeps file2.txt
Now how can I add the the content of file1.txt to file2.txt (below the content of file2.txt)
like this
OK Green > start 1
No Green > start 2
No Green > start 3
No orange > start 1
Ok orange > start 2
No orange > start 3
OK red > start 1
OK red > start 2
No red > start 3
OK Green > start 1
OK Green > start 2
No Green > start 3
OK orange > start 1
No orange > start 2
No orange > start 3
OK red > start 1
OK red > start 2
OK red > start 3
My Question is below, " how can i copy these data from files to array and viseversa(
Are you trying to write your own network communications protocol or something? This seems like a strange approach to get data from one PC to another. Why not just use Boost or Win32 to write a network app?
Appending a text file to another is done by opening both files (the one you want to append to with the ate or app flag) and using getline to read lines from one file, then writing it to the other.
Edit:
1 2 3 4 5 6 7 8
ifstream in("src.txt");
ofstream out("dest.txt",ofstream::ate);
string line;
while (in)
{
getline(in,line);
out << line << '\n';
}
Your code appears to be unnecessarily complicated.