I'm not sure what I'm doing wrong in this project, but the values I'm getting don't ring true to what they should be (the value printed to the window should be 4, but instead i get like 22586 or something)
Code:
ifstream fin(fileName, ios::in | ios::binary | ios::nocreate);
if(fin.fail()){
MessageBox(NULL, "UNABLE TO OPEN MODEL FILE", "ERROR", MB_OK);
return;
}
char x[50];
fin.seekg(0, ios::end); //SEEK TO END OF FILE, STREAM OFF
long filesize = fin.tellg(); //GET SIZE IN BYTES OF FILE
fin.seekg(0, ios::beg); //SEEK BACK TO BEGINNING
byte*buffer = new byte[filesize];
fin.read(buffer, filesize); //READ STUFF FROM FILE INTO A BUFFER
fin.close();
const byte * ptr = buffer;
MS3DHeader *pHeader = (MS3DHeader*) ptr;
ptr += sizeof(MS3DHeader);
sprintf(x, "version: %d", (int)pHeader->m_version);
SetWindowText(hWnd, x);
Sleep(tts);