Jump to content
  • Advertisement
Sign in to follow this  
Assassinbeast

How important is the iostream in gamedev?

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

Hello folks :-)

 

I just wanna ask how important it is to learn/master the basics of iostream in c++.

 

eg:

 

cin.fail

cin.good

cin.clear

cin.bad

cin.putback

cin.get

cin.getline

cin.eof 

 

and all that bullshit.

 

for me, its kinda hard to remember because i never use it when i make games, and i never use it when i test my own code (only cout and cin), but sometimes when i read books, they use it. So its getting  hard and frustrating to remember how the iostream is made and when the states are set.

Share this post


Link to post
Share on other sites
Advertisement
In practice, 99.9% of your usage of cin will be calling std::getline(std::cin, ...), and of cout will be simple stream operators (i.e. std::cout << "Hello, World!" << std::endl). If you stat working with actual files, you will probably be paying attention to eof() and good(), but generally not a whole lot more than that.

 

However, it's all useful knowledge to have, so you might as well learn it...

 

    Good advice swift, I would like to expand a bit on this.  "Streams" in general can be a very helpful tool in creating anything including games, the cin and cout feature families (for lack of a better term) are not the only way to handle streaming of data.  In more modern cases they are actually being used less and less as coders are preferring more versatile streaming options.  It is wise to have a base knowledge of streaming in general and the cin / cout feature families are a good entry level exposure to this information but I wouldn't spend excessive amounts of times learning the specifics of these two functions exactly.  More so the << and >> operators and the idea that a stream is a buffered portion of memory (be it in RAM or on DISK) are the important part.  When you get into file i/o and socket i/o you will find streams start making everything easier and more expandable.  Beyond inter process communications (thread to thread or app to service type techniques), file streaming and socket communications there won't be many cases where streams will be very important.

Share this post


Link to post
Share on other sites
In practice, the IO stream classes aren't used much.

I've never worked on a major game where the C++ standard library IO was used (and on many projects the whole library is ignored anyways). The IO stream classes are nice for bootstrapping simple games or getting prototypes running, but heavy-duty file and socket IO, code usually needs to do things that the standard classes just don't support in any clean way.

Share this post


Link to post
Share on other sites
Its not important to master the basics of anything until you need to use it. Learning to use classes to prepare yourself for some hypothetical future use is redundant.

It's important to learn how to find and digest documentation to figure out how to use things when you need them.

"Give a man a fire, he will be warm for a day. Set a man on fire, he will be warm for the rest of his life" - Terry Pratchett Edited by Aardvajk

Share this post


Link to post
Share on other sites

It is good to know what exists, because that way you don't find yourself doing things the hard way due to ignorance. Of course, the balancing act then becomes how much time do you spend understanding the "existence" of something.

 

Even though C++'s standard library is relatively small in comparison to modern languages, there is still enough there that a beginner would have difficulty getting to the point of knowing what exists in any meaningful manner. Some of the ideas are going to be utterly foreign until you have some practical grounding in the language and computer science in general.

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!