Here is a simple code in C++:
cout << "Press Any Key To Exit...";
What is the code for closing program when user presses any button on keyboard. What should I write after above code?
I know I can use cin.ignore(); and if user presses Enter the program will close, But my target is any key.
How to do that?
You can use the ncurses library to do this. The downside to this solution is that you won’t be able to use cout for outputting anymore.
Be sure to
-lncurseswhen compiling