Loading And Reading From Files

Started by
2 comments, last by BrokenCloud 21 years, 2 months ago
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
Incoming Message:Help! Help! My Cloud Is Gone!!!
Advertisement
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.
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?)
Incoming Message:Help! Help! My Cloud Is Gone!!!
ifstream - input to your program
ofstream - output from your program

This topic is closed to new replies.

Advertisement