Lots of problems:
Code:
-seekg(-14, ios::end) tells it to seek +14 past the end of file.
-length = textureRead.tellg();
-tellg() returns an error code, probably -1 -> 0xFFFFFFFF
-buffer = new char [length];
-You're creating a (4gb - 1byte) buffer!
-textureRead.close();
-Uh oh, you just closed the file. textureRead.good() != true
-thus, it will only work if it reads it all in in 1 go, which you're trying to do, but then you don't need the while.
-You didn't delete[] buffer! memory leak of 4gb right away!
I believe this would be a better solution all around:
Code:
char buffer[256];
textureRead.seekg(15);
while (textureRead.good())
{
textureRead.read(buffer, 256);
textureWrite.write(buffer, textureRead.gcount());
}
textureRead.close();
textureWrite.close();
//buffer isn't dynamically allocated so you don't need to delete[] it
Hope this helps
**EDIT**
Clear the buffer in which way? To initialize it to all 0's, do:
char buffer[256] = {0};
To free it, do:
char* buffer = new char[256];
delete[] buffer; //Only because buffer is dynamically allocated