Archived

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

BrokenCloud

Loading And Reading From Files

Recommended Posts

Hi, Here''s a snippet of something
fstream File;
File.open ("IDList.def", ios::out);
for (iloop = 0; iloop <= ID_Number; iloop++) {
   File.ignore (10000, ''[dr]'');
}
File.getline (WeapName, 50);
cout << WeapName;
 
and I have a file called IDList.def which has [dr]Mydoc.gif [dr]Something.jpg [dr]Mypic.doc It''s all in text format not binary (I can read it in notepad) Anyways, when I do that, it gives me several strange symbols. What i''m trying to do is get an id of an item, for loop it that many times untill the it reaches the id which should match the line number and output whatever is after the [dr]. Any solutions? Thanks

Share this post


Link to post
Share on other sites
If you intend to read data from the file, then you shouldn''t be opening it with the ios::out flag, which explicity tells the stream you will be writing data. Use ios::in, or use an ifstream instead of an fstream if all you plan to do is read in with that stream variable.

Share this post


Link to post
Share on other sites