• ### Popular Now

• 9
• 10
• 9
• 10
• 10

#### Archived

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

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

## 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 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 on other sites
I got confused, I guess that could be the problem... hmm... i''ll try the ifstream too. Thanks. (in as in input to the file orrr.. input to the screen? confusing?)