Jump to content
  • Advertisement


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


Loading And Reading From Files

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

If you intended to correct an error in the post then please contact us.

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
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?)

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!