IWriteFile and writing inside an iteration

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
Murloc992
Posts: 272
Joined: Mon Apr 13, 2009 2:45 pm
Location: Utena,Lithuania

IWriteFile and writing inside an iteration

Post by Murloc992 »

Got this strange issue or maybe lack of knowledge about writing files in irrlicht. I have a list of stringc, nothing special. What I want to do is to write every single member of the list into a file. Strange things happen when I just do:

Code: Select all

for(it=li.begin(); it!=li.end(); it++)
{
wf->write((&it),sizeof(&it));
}
When I put a break; after the writing it passes ok, the data of only the first member is there, but else the app freezes and the file keeps growing in size infinitely. And yes, I want to write things like this, I just need help with writing during the iteration.

Thanks in advance.
Sylence
Posts: 725
Joined: Sat Mar 03, 2007 9:01 pm
Location: Germany
Contact:

Post by Sylence »

&it is a reference to the iterator. You can't write this into a file.
You want the string the iterator refers to:

Code: Select all

wf->write( (*it).c_str(), (*it).size() );
Software documentation is like sex. If it's good you want more. If it's bad it's better than nothing.
Murloc992
Posts: 272
Joined: Mon Apr 13, 2009 2:45 pm
Location: Utena,Lithuania

Post by Murloc992 »

Sylence wrote:&it is a reference to the iterator. You can't write this into a file.
You want the string the iterator refers to:

Code: Select all

wf->write( (*it).c_str(), (*it).size() );
Oh, thanks about that one. Gonna see if it succeeds to write the entire list when I am back home. :)
Post Reply