How do I code something to where if any key is pressed it will do something such as returning a small program to its original state? I was thinking that an "if" statement would work with an "or" operator, however it would be tedious to do every key. I am a beginner so any help would be appreciated, as I am completely confused right now.
#include <iostream>
#include <conio.h> // include this to use the _getch() function
int main()
{
std::cout << "Pressing Any Key to Achieve Something: Test' << std::endl;
std::cout << "press any key to continue . . . ";
_getch();
std::cout << "Good Job! Press any key to exit . . .";
_getch();
std::cout << endl;
std::cout << "Terminating Program..." << std::endl;
return 0;
}
Hope that helps. Play around with it to get the results you want.
If you have something more specific in mind, i'd be happy to help.