Archived

This topic is now archived and is closed to further replies.

sizeof()

This topic is 5974 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I ran into a little problem today using sizeof() and was hoping someone could clear it up for me. Im writing a basic 3ds loader and have a struct declared like so: struct _3DSCHUNKHEADER { WORD ChunkID; DWORD ChunkLength; }; When I use sizeof() to read a chunk header ... _3DSCHUNKHEADER ChunkHeader; fread(&ChunkHeader, sizeof(_3DSCHUNKHEADER), 1, file); its reading 8 bytes instead of 6, anyone know why? When i break it up into 2 freads ... fread(&ChunkHeader.ChunkID, sizeof(WORD), 1, file); fread(&ChunkHeader.ChunkLength, sizeof(DWROD), 1, file); it works fine. sizeof(WORD) = 2; sizeof(DWORD) = 4; sizeof(_3DSCHUNKHEADER) = 8; Im Confused. Edited by - SoGreen on August 9, 2001 4:58:17 PM

Share this post


Link to post
Share on other sites