Vaild pause?
-
Real quick: Is this a valid way to pause a consle program?
cout<< "Press ENTER to continue..."; //Informs the user what is happening
cin.ignore(); //clears the cinstream of any stray characters
cin.get(); //pauses until user presses ENTERI have heard that you want to avoid system calls like
system("pause");
, so is this a viable option? Thanks -Mark
We're sorry, we were unable to complete you request. The website administrator has been automatically notified. REFRESH?
¥492077616E74206120726566756E6400¥
-
Real quick: Is this a valid way to pause a consle program?
cout<< "Press ENTER to continue..."; //Informs the user what is happening
cin.ignore(); //clears the cinstream of any stray characters
cin.get(); //pauses until user presses ENTERI have heard that you want to avoid system calls like
system("pause");
, so is this a viable option? Thanks -Mark
We're sorry, we were unable to complete you request. The website administrator has been automatically notified. REFRESH?
¥492077616E74206120726566756E6400¥
You could try using
Sleep()
or simply loop until the requisite number of seconds have elapsed.int nElapsed = 0;
int nWaitFor = 5; // wait 5 seconds
time_t tmStart;time (&tmStart);
do {
time_t tmNow;
time (&tmNow);
nElapsed = tmNow - tmStart;
} while (nElapsed < nWaitFor);/ravi My new year's resolution: 2048 x 1536 Home | Articles | Freeware | Music ravib@ravib.com
-
Real quick: Is this a valid way to pause a consle program?
cout<< "Press ENTER to continue..."; //Informs the user what is happening
cin.ignore(); //clears the cinstream of any stray characters
cin.get(); //pauses until user presses ENTERI have heard that you want to avoid system calls like
system("pause");
, so is this a viable option? Thanks -Mark
We're sorry, we were unable to complete you request. The website administrator has been automatically notified. REFRESH?
¥492077616E74206120726566756E6400¥
system()
is almost always a bad choice. :) -- My name in Katakana is ヨルゲン. My name in German is Jörgen. I blog too now[^] -
You could try using
Sleep()
or simply loop until the requisite number of seconds have elapsed.int nElapsed = 0;
int nWaitFor = 5; // wait 5 seconds
time_t tmStart;time (&tmStart);
do {
time_t tmNow;
time (&tmNow);
nElapsed = tmNow - tmStart;
} while (nElapsed < nWaitFor);/ravi My new year's resolution: 2048 x 1536 Home | Articles | Freeware | Music ravib@ravib.com
What if I want to wait for user input? Different people take a different amount time to read and understand the same info. Make the time too short and the user gets pissed off b/c they missed something, too long and they sit there pounding to keyboard trying to progress in the program. -Mark
We're sorry, we were unable to complete you request. The website administrator has been automatically notified. REFRESH?
¥492077616E74206120726566756E6400¥
-
What if I want to wait for user input? Different people take a different amount time to read and understand the same info. Make the time too short and the user gets pissed off b/c they missed something, too long and they sit there pounding to keyboard trying to progress in the program. -Mark
We're sorry, we were unable to complete you request. The website administrator has been automatically notified. REFRESH?
¥492077616E74206120726566756E6400¥
---Mark--- wrote: What if I want to wait for user input? You don't have to do anything special to wait for user input.
cin >> foo
won't complete until the user presses Enter. /ravi My new year's resolution: 2048 x 1536 Home | Articles | Freeware | Music ravib@ravib.com -
---Mark--- wrote: What if I want to wait for user input? You don't have to do anything special to wait for user input.
cin >> foo
won't complete until the user presses Enter. /ravi My new year's resolution: 2048 x 1536 Home | Articles | Freeware | Music ravib@ravib.comMaybe that was confusing. I didn't mean actual input like a number or character, I meant to wait for the user to acknowledge that what is being displayed on the console has been read and the program can progress or end. In that case is the way I mentioned a good way to do that or are there better? Thanks -Mark
We're sorry, we were unable to complete you request. The website administrator has been automatically notified. REFRESH?
¥492077616E74206120726566756E6400¥
-
Maybe that was confusing. I didn't mean actual input like a number or character, I meant to wait for the user to acknowledge that what is being displayed on the console has been read and the program can progress or end. In that case is the way I mentioned a good way to do that or are there better? Thanks -Mark
We're sorry, we were unable to complete you request. The website administrator has been automatically notified. REFRESH?
¥492077616E74206120726566756E6400¥
Ah, gotcha. I don't know you'd do that in a console program without resorting to assembly programming. I did something similar decades ago on a VMS system - my function waited for user input for upto "n" seconds. This kind of stuff is easy to do in a GUI Windows app. /ravi My new year's resolution: 2048 x 1536 Home | Articles | Freeware | Music ravib@ravib.com