Sign in to follow this  

Problem solved, thanks.

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

This topic is 4168 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this