I'm simply trying to read a small 1KB binary file into a buffer and then write the buffer back to the disk. It seems that for some files the outputfile is completely different from the Inputfile, what am I doing wrong? Thank you very much.
std::ifstream myfile; myfile.open (testinput.rar); myfile.seekg (0, myfile.end); filesize = myfile.tellg(); myfile.seekg (0, myfile.beg); char *mybuffer= new char[filesize]; myfile.read(mybuffer,filesize); myfile.close(); ofstream myfile3; myfile3.open ("testoutput.rar"); for(unsigned int i=0; i<filesize; i++) myfile3 << mybuffer[i]; myfile3.close();
myfile.open (testinput.rar);? Can't imagine that would even build.