Archived

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

WizHarDx

damn fstream

Recommended Posts

Hi I am making the level editor for my game, its working fine but when I save & then load it does not work correctly. In the structure I am saving it has 3 HBITMAPS & 2 Arrays. I am guessing the problem is that the struct contains pointers so it is saving the memory address not the data or something like that , anyways do any of you know how to overcome this problem. thanx in advance WizHarD

Share this post


Link to post
Share on other sites
be sure when saving to a file to save the objects, like you said, not the pointers. For example.

  
int* data = MyDataLoader();
//BAD

MyWriteFunction(data);
//GOOD

MyWriteFunction(*data);


You could always write each member of the structure, or make it into a class with a save function. Since I tend to lean towards classes anyway, the second is what I would do.

Alex Broadwin
A-Tronic Software & Design
-----
"if you fail in life, you were destined to fail. If you suceed in life, call me."
"The answer is out there."
"Please help, I''m using Windows!"

Share this post


Link to post
Share on other sites
You cannot save the HBITMAPs directly because they are handles. You must get the bitmap header data (dimensions, bits-per-pixel, etc.) and save it into a file yourself. If you do not need a custom format then you should use the Windows bitmap file format (BMP). Wotsit.org should have information about this.

Share this post


Link to post
Share on other sites