jjhaag beat me to the punch, but here is my program updated to read the size of the file and then write it. I use seekg to move to the end of the file, grab the position, clear the pointer (because it is in an error state) restart at the beginning and then go about setting up the rest of the read write. Notice I also remove any mention of sizeof and just use the size read in.... aka the file size.
CODE
int main() {
// Oopen the file as an ifstream
ifstream f("C:\\bollock\\usbimage2.txt", ios::in);
// Get the size
f.seekg(0,ios::end);
long x = f.tellg();
f.clear();
f.seekg(0,ios::beg);
// Notice we make a pointer of certain char size.
// You can't use variables as subscript unless it is done this way.
char *buffer = new char[x];
// Read into the buffer (notice no ampersand, this was the pointer problem)
f.read(buffer,x);
f.close();
// Use an output stream and write out, again no ampersand
ofstream g("C:\\bollock\\new.txt", ios::out);
g.write(buffer, x);
g.close();
return 0;
}
My bad for not taking this further.
This post has been edited by Martyr2: 8 Jan, 2008 - 02:39 PM