In my console programs i want to be able to pause the program. How do i make the program wait for the enter button to be pressed (without entering a char or number into a variable).
Like the "Press enter to continue" thing....
In my console programs i want to be able to pause the program. How do i make the program wait for the enter button to be pressed (without entering a char or number into a variable).
Like the "Press enter to continue" thing....
Code:#include <cstdlib> using namespace std; ... system ("pause");
Hope that helps. Should work, that is what I always use.Code:#include <iostream.h> #include <conio.h> int main() { cout<< "Hi there.\n"; cout<< "Hit any key to exit program..."; getch(); // This will pause the program until some key is hit return(0); }
/* Number 1 */
Displays:Code:#include <iostream.h> #include <stdlib.h> int main() { cout<<"And you died..."<<endl; system("pause"); /* Note: only usable in dos: Reason: It calls the dos command 'pause' */ return 0; }
And you died...
Press any key to continue . . .
/* Number 2 */
this uses the function kbhit() to see when a key is hit...Code:#include <iostream.h> #include <conio.h> int main() { cout<<"And you died..."<<endl; cout<<"Press any key to continue . . ."<<endl; if(kbhit()) { return 0; } return 0; }
Hope this helps....man I have no life when I typed all that to answer a question
+++
++
+ Sekti
++
+++