Hello
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?Code:ifstream in("file1.dat",ios::binary); ofstream out("file2.dat",ofstream::binary); in.seekg(0, ios::end); unsigned long file_size = in.tellg(); in.seekg(0, ios::beg); char *buffer; buffer = new char [file_size]; in.read(buffer,file_size); out.write(buffer,file_size);
Later I need to read the file bytewise so I would do it withis this fast or is in.get() faster...?Code:in.read(buffer,1); out.write(buffer,1);
Thanks in advance.
slapy



LinkBack URL
About LinkBacks


