I want to read in a file binary (manipulate it) and write it back to a file. In other words I would like to copy a file.
I thought this code should do it but I tried to copy a 1.11KB big file and the result file was just 1KB. Why? And is this an efficient way to read and write or is there a quicker possibility?
unsigned long file_size = in.tellg();
buffer = new char [file_size];
Later I need to read the file bytewise so I would do it with
is this fast or is in.get() faster...?
Thanks in advance.
Probably the fastest way to copy a file in C++ is:
Also you have this:
> ofstream out("file2.dat",ofstream::binary);
Which should be:
That's probably why it only copied 1KB vs 1.11KB.