Pressing any key to achieve something?

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.
Google it. You'll find lots of suggestions

Here is one
http://stackoverflow.com/questions/24708700/c-detect-when-user-presses-arrow-key
Let me know if this doesn't work...

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#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.
Last edited on
Topic archived. No new replies allowed.