Jump to content
  • Advertisement

Archived

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

BeanDog

file i/o woes - o works, i needs work

This topic is 6920 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Here is a small chunk of my file output thingy: savefile.write((char*)&Creatures, sizeof(Creatures[0][0])*2400); where Creatures is a 8x300 array of classes. The output seems to work fine (I realize this is not optimized, I don''t care I want it to WORK first), but when I try to read it, it goes real real quick and doesn''t seem to get anything from the file. Here is my input code: savefile.read((char*)&Creatures, sizeof(Creatures[0][0])*2400); Simple, right? Yes, I closed the file between them and it is a ifstream the second time. This is all the change I should need to read instead of write, correct? ~BenDilts(void* Intelligence); Bean Dog

Share this post


Link to post
Share on other sites
Advertisement
Well maybe if you posted the actual code that is broken, and not just the function call to it.
That one line looks good, if thats what you wanted to know?

Share this post


Link to post
Share on other sites
Random guess: you are saving it out in text mode, and when you read it in text mode, it finds an End-Of-File character (-1, or 255) and stops right there. Try binary mode...

Share this post


Link to post
Share on other sites
I am not going to have a chance to check the binary thingy for a few days (I program so much I''m banned from it by my mom on Sunday, Monday, and Tuesday), but it may be the binary thingy.

BTW, savefile is an fstream object, I cannot get to the code for the functions ''read'' or ''write''.

Could the problem be that my class has a bunch of member functions? All my data types are public, so that shouldn''t be a problem. The char cname[50] shouldn''t be giving any troubles, should it, because that technically is a pointer. The member functions would be my first guess. Is it writing the memory used for those functions to disk?

~BenDilts(NULL* Brain);

Share this post


Link to post
Share on other sites
quote:
Original post by BeanDog

BTW, savefile is an fstream object, I cannot get to the code for the functions ''read'' or ''write''.


Not that it should matter here, but yes you can. It''s all in the headers somewhere. Just build with browse info enabled, right click on ''read'' or ''write'' and select ''go to definition''. It should take you to the relevant header.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!