Little problem with sizeof on PC

Noam Mendelson c60b-1eq at e260-1g.berkeley.edu
Wed Apr 24 13:24:28 AEST 1991


In article <1991Apr23.155042.5532 at ux1.cso.uiuc.edu> allender at cso.uiuc.edu (Mark Allender) writes:
>Just a followup to me problem with the word alignment in this structure..
>The data that I am reading in someone else's form, and has to stay this way.
>I can't change it.  And indeed, I would rather have the data in raw binary
>form.  There is a filler byte inserted after the filler2[15] declaration.
>The best suggestion around this was to read the entire 201 bytes into
>a char buffer[201] array, and then memcpy the elements into their corresponding
>location.

How about reading the struct in two steps, first reading everything up to
the end of filler2[] (not including the byte padding), then reading the 
rest into the float number?
That would be much more efficient (memory- and speed-wise) than that
e-mail suggestion.

-- 
+==========================================================================+
| Noam Mendelson   ..!ucbvax!web!c60b-1eq       | "I haven't lost my mind, |
| c60b-1eq at web.Berkeley.EDU                     |  it's backed up on tape  |
| University of California at Berkeley          |  somewhere."             |



More information about the Comp.lang.c mailing list