Advertisement

Lesson 32 question

Started by December 22, 2001 02:40 PM
0 comments, last by nitzan 23 years, 2 months ago
I have the following piece of code taken from Lesson 32: -------- byte *pBuffer = new byte[fileSize]; inputFile.read( pBuffer, fileSize ); inputFile.close(); const byte *pPtr = pBuffer; MS3DHeader *pHeader = ( MS3DHeader* )pPtr; pPtr += sizeof( MS3DHeader ); -------- MS3DHeader is defined as follows: -------- struct MS3DHeader { char m_ID[10]; int m_version; }; -------- Now, when I look at the debugger, pBuffer[10] = 4. Which means m_version should be equal to 4. When I run the Lesson32 code, this is correct. When I run my code (which is pretty much identical) I get m_version = 2621440. Does anyone have any ideas why this is happening ? Nitzan ------------------------- www.geocities.com/nitzanw www.scorchedearth3d.net -------------------------
I solved the problem. The structure was not byte aligned.

Nitzan

-------------------------
www.geocities.com/nitzanw
www.scorchedearth3d.net
-------------------------

This topic is closed to new replies.

Advertisement