In C I'm trying to select a specific member of a struct and print it out. I wonder, what is the suggested format for such an operation? I've tried nearly everything I can think of. I can't seem to limit it to the specific
fseek(in, sizeof(d.contents.datas.chunk), SEEK_SET);
fread(&ch, 1, 1, in);
fprintf(out, "%02x", (int)(ch & 0x00FF));
You are seeking to the wrong place in the file. Assuming the endian of your machine is the same as the endian of the file, then this will work:
fseek(in, long(&d.content.data.chunk - &d), SEEK_SET); fread(&ch, 1, 1, in); fprintf(out, "%02x", (int)(ch & 0x00FF));
The first line calculates the offset in bytes of chunk in the structure. You were using the sizeof(chunk) which of course just returns 1.
If the endian is different, then you will have to convert each non char character to the correct endian after reading in the structure.