Reading structs with fread

Started by
0 comments, last by executor_2k2 21 years, 11 months ago
Im working on an animation parser for .3ds files, and I need to read in info from sturcts. Here''s the struct struct { short framenum; long unknown; float pos_x, pos_y, pos_z; } pos[keys]; pos[keys] is an array of the above struct. How would I use fread to get this data? I have only used fread to get integer data in my code so far. Thanks for any help.
Well, that was a waste of 2 minutes of my life. Now I have to code faster to get 'em back...
Advertisement
Well if you call your struct something like

struct pos_t {
short framenum;
long unknown;
float pos_x, pos_y, pos_z;
} pos[keys];

You can read it with fread like this ...

fread(pos, sizeof(pos_t), keys, file);

... where file is an open file. Check out the MSDN reference here.

Edit: fixed link

[edited by - Mr_Burns on May 2, 2002 11:17:15 PM]

This topic is closed to new replies.

Advertisement