- Jan 21, 2005
- 17,722
- 6
- 81
I just want to know how I can set it so that it doesn't close the DOS window when I compile/execute it.
Originally posted by: xtknight
I actually just noticed cin.get() didn't work on the second call. No idea why...
What's the C++ equivalent of getch()? Anyone?
I think it's because it still keeps the first input.Why does cin.get() not work on the second call?
That semi colon will make it loop on that one statement, thereby doing nothing.while(1);
That won't help.try doing a void main() and do not return 0;.
I usually just use getchar() anyway.What's the C++ equivalent of getch()? Anyone?
Originally posted by: xtknight
Why does cin.get() not work on the second call? It wasn't halting the program for me as I remember, and apparently not for the OP either.
Yes, but the window won't close.Originally posted by: BFG10K
That semi colon will make it loop on that one statement, thereby doing nothing.while(1);
Originally posted by: dighn
Originally posted by: xtknight
Why does cin.get() not work on the second call? It wasn't halting the program for me as I remember, and apparently not for the OP either.
cin.get() does not clear the input buffer of carriage returns, so the next retrieval completes immediately. you can work around it by using the ignore methd cin.ignore('\n', 999); or something like that