I have this issue, I don't know if is expected, here is the thing:
I'm trying to load bytes from a file to an structure like this:
struct
{
char
char
char
char
unsigned int
}
but the problem is when the unsigned int is filled, it seems like in the reading stream the bytes are swapped, e.x. if the file contains 0x45080000, the unsigned int will have 0x84500000, which is wrong.
This can be "solved" if i change the unsigned int for a BYTE[4], but is not what I want. Here is the code that I use to read from the file:
fopen_s( &mFile, "myFile.ext", "rb" );
if( mFile == NULL ) print( " **** E R R O R ! **** " );
else
{
if( fread( &myStruct, sizeof( MY_Struct ), 1, myFile) != 1)
{
print( " **** E R R O R ! **** " );
return 0;
}
}
Is this an expected behavior or what am I doing wrong?
Regards