Sign in to follow this  
MattHughes

[C++] Bytes stored in reverse? [resolved]

Recommended Posts

Hi, I'm trying to read some binary data from a file. In the file are four bytes: 00 00 DE 51 (in hex), corresponding to an integer with the value 56913. I read the file with ReadFile(...) in the windows.h library. My problem is that when I print it out it has a value of 51 DE 00 00! When I print this as an integer it is 1373503488 which is definitely wrong. So it seems to me that the bytes stored in the file are in the opposite order of how bytes are stored in memory. Does anyone know how I might fix this? Should I "flip" the order of the bytes that I read, or can I read the file differently? Thanks! [Edited by - MattHughes on May 7, 2008 11:02:18 AM]

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this