Jump to content
  • Advertisement
Sign in to follow this  
Adams555

Problem solved, thanks.

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

Trap had the solution. Thanks very much for the prompt reply! Hello. I'm working on a checkers program, and I'm having a bit of a problem.. I'm using the console to draw the board each frame.. But for some reason, cout isn't printing to the screen when I tell it to! It seems as if it fills up its buffer, and then dumps everything to the screen at once. Look at this loop, here. while(true){ system("pause"); cout<<"This is a test\n"; } Simple, right? It should display "Press any key to continue", and then when you press a key, it should display "This is a test" and start over. Right? Nope! You have to press a key about 35 times, and then it will dump all of the stored "This is a test" lines to the screen. It even splits the output! You get something like This is a test This is a test This is a test This is a tPress any key to continue . . . <- notice this line.. Press any key to continue . . . I can also confirm that this is not caused by the system("pause"). If I use Sleep(100) instead, it waits about 3 seconds, displays 35 lines of "This is a test", waits another 3 seconds, displays 35 more lines, etc. Any clue how to print to the console without this strange delay? Thanks much for your help, Adam

Share this post


Link to post
Share on other sites
Advertisement
cout.flush();
or
use cout << std::endl; which outputs '\n' and flushes the output afterwards
or
use cin.get() instead of system("pause"), reading from cin automatically flushes cout.

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!