Hello to the forum, perhaps someone can help me. I am trying to read a file that has the following format:
128 byte header
float data
When reading the header, I need to extract the following from the header:
bytes0-6= short unsigned int big endian
byte7 = int
bytes8-23= float little endian
byte24= int
so here is what I have done:
short max_x, max_y, max_z;
fread(&max_z, sizeof(short), 1, fp);
fread(&max_y, sizeof(short), 1, fp);
fread(&max_x, sizeof(short), 1, fp);
Given that the first four values in the header are 100, 100, 100, 1, when I check what have for max_x, max_y, max_z, I should get 100, 100, 100, however
printf("%hu",
variable);
gives me 25600 for each.
Am i messing up the printf, or is there something else I need to do in order to read the data properly. Thank you!