Jump to content
  • Advertisement
Sign in to follow this  
mirza101

file handling with c++

This topic is 4615 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

stdio or fstream i know i can handle files with both libraries but which of these two is faster and why are there two libraries that can do the same thing, i mean what is the use of it??

Share this post


Link to post
Share on other sites
Advertisement
stdio is from the C standard library, and fstream is from the C++ standard library. As you're using C++ you should prefer to use the C++ standard library so I would recomend using fstream.

Share this post


Link to post
Share on other sites
Its pure prefence, really. I prefer to use 'the C way' instead of 'the c++ way', but thats just becuase I feel that it is more readable, at least to me. Pick wichever.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Quote:
Original post by mirza101
stdio or fstream

i know i can handle files with both libraries but which of these two is faster and why are there two libraries that can do the same thing, i mean what is the use of it??



Depending on your requirements Raw File IO can be fastest (loads file/system aligned blocks -- so is good for low level stuff and bulk loading of assets etc...)

Share this post


Link to post
Share on other sites
Roughly speaking the C style I/O routines have better performance. However, that tends to be unimportant as things like file I/O tends to be bounded by the disk access. Also, it's pretty easy to create resource leaks using C style I/O with C++ classes.

On the other hand, C++ style I/O routines have better exception safety, type safety and aren't prone to many of the errors that you can get with C style I/O.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • 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!