file i/o woes - o works, i needs work
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
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?
That one line looks good, if thats what you wanted to know?
Just because the church was wrong doesn't mean Galileo wasn't a heretic.It just means he was a heretic who was right.
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...
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);
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);
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.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement