using memcpy to copy 2 dim array contents ? plz Help me

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(
Last edited on
As far as I can tell, you want to append file1 to file2. Is this correct?

The code seems awefully complicated.

I can say categically, using memcpy on C++ objects is wrong.
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?
THANKS GEEK and kbw,

yes it is append, it is nothing to do with protocol, but what I am asking is how to deal with strings in array thats alll guys

is there anyone who has a good experience in (c++) esp strings which going to help me on this plz ??
Last edited on
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.
Last edited on
No it is not append sorry,

Thanks guys for the tries and the help ;)
Last edited on
Topic archived. No new replies allowed.