Reading structs with fread
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 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]
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
Popular Topics
Advertisement