Jump to content
  • Advertisement


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


fstream help

This topic is 5992 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 all, Can anyone give me a crash course on fstream and how I would read info from a file into my program. I am trying to figure it out with MSDN Visual Studio but its worded to the point where I cant figure it out. thanks NextGenGamer

Share this post

Link to post
Share on other sites
Watch out

This 'tutorial' uses <iostream.h> and <fstream.h>. This is bad. The pre-Standard headers are only there for backward compatibility. The old iostream library has been deprecated (i.e. they would have taken it out completely if it wouldn't break legacy code).

Don't get bad habits. Start with <iostream> and <fstream>. It will save you no small amount of grief when you'll start to actually manipulate the streams.

e.g. The old iostream (file or not) reads into a char[] while the new std::iostream read into a std::string... which means that you don't have to worry about buffer overflow, memory allocation or how to assign and compare strings.

You can find the GNU standard iostream reference there

Edit: Ok, the general principles apply, but not the nitty-gritty details.

Documents [ GDNet | MSDN | STL | OpenGL | Formats | RTFM | Asking Smart Questions ]
C++ Stuff [ MinGW | Loki | SDL | Boost. | STLport | FLTK | ACCU Recommended Books ]

[edited by - Fruny on June 27, 2002 1:16:22 AM]

[edited by - Fruny on June 27, 2002 2:16:25 AM]

Share this post

Link to post
Share on other sites
Original post by Fruny
This 'tutorial' uses < iostream.h > and < fstream.h >.

Whoops! Sorry, didn't notice that. I guess I should have looked at the page a little more closely.

/* Chem0sh */
/* Lead Software Engineer & Tech Support */
/* http://www.eFaces.biz */

[edited by - Chem0sh on June 27, 2002 1:18:18 AM]

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!