Help! XL save file
ok, i am writing a gta style game, and i am trying to set up a system to save the city data. my city is in a 256x256x7 array of classes (next thing on list is to change to array of pointers to classes)
When i save, i save a 30k header(ish) and then call each block in turn to save itself. this creates a 527mb file? each fwrite is returning 36 as the bytes written. is it me, or should it only be taking 15 megabytes? ((256*256*7)/1024)/1024
code of writing:
struct boxstorage {
//Textures
int TopTex;
int ScreenTopTex;
int ScreenBotTex;
int LeftTex;
int RightTex;
//draw
bool exists;
//Colours
float r, g, b;
} thisbox;
thisbox.TopTex = TopTex;
.
.(others)
.
thisbox.b = b;
return fwrite ( &thisbox, sizeof(boxstorage), sizeof (boxstorage), (FILE*)Filehandle );
fwrite() returns the number of full items written, which is sizeof(boxstorage) in your case (the error). The third parameter of fwrite() is not how many bytes to write, but how many items to write, so if you only want to write the structure once then move on to the next then you should set the third parameter to 1.
Invader X
Invader''s Realm
Invader X
Invader''s Realm
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement