Many C programs read data from disk into structures and write data to disk from structures. The functions that perform disk I/O in C require you to specify the number of bytes to be transferred. You should always use the sizeof operator to obtain the size of the data to be read or written because differing data type sizes or alignment schemes may alter the size of a given structure. For example,
fread( &my_struct, sizeof(my_struct), 1, fp );
When performing disk input and output in Microsoft C, structures may be different sizes depending on the structure-packing option you have selected (see the /Zp compiler option in Chapter 13, “CL Command Reference,” of the Environment and Tools manual; see the pack pragma in the C Language Reference or in Help).