How can I make a C++ Program pause for a while????
I was just wondering how to make a C++ Program pause for a given amount of time because one of my messages just blares by on the screen and you can''t read it. If you know how either post it or email me.
Thanks,
ProgrammingMan
chris42386@hotmail.com
If you are printing via the console (cout or printf), then its easy. Have the problem print a few lines then add a line of code, a cin statement or scanf. In these statements, just read in a dummy character. This will "pause" your output.
Something like this:
scanf("%c", &cDummyChar);
Then, when you run the program, you will see a few lines of output then you will enter a character and press enter to cause the output to resume. If you are in a loop, make a small counter that executes the sscanf about every 20 output lines or something.
Something like this:
scanf("%c", &cDummyChar);
Then, when you run the program, you will see a few lines of output then you will enter a character and press enter to cause the output to resume. If you are in a loop, make a small counter that executes the sscanf about every 20 output lines or something.
sleep() for whole seconds or
usleep() for milliseconds.
if you don't know how many times it will get printed out, try something in manner of:
/Mikael Jacobson
![](http://www.crosswinds.net/~druidgames/resist.jpg)
Edited by - mikael_j on April 1, 2001 12:06:44 PM
usleep() for milliseconds.
if you don't know how many times it will get printed out, try something in manner of:
|
/Mikael Jacobson
![](http://www.crosswinds.net/~druidgames/resist.jpg)
Edited by - mikael_j on April 1, 2001 12:06:44 PM
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement