Archived

This topic is now archived and is closed to further replies.

executor_2k2

Reading structs with fread

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites