RandomNumberGenerator

instead of typing roll i would like to just press a button. how would i do that

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
 #include <iostream>
#include <cstdlib>
#include <ctime>

using namespace std;

int main()
{
    string answer;
    string roll;

    cout << "Are You Ready For A Dice Game?" << endl;
    cin >> answer;
    if (answer == "yes")
    {
        cout << "Let's Begin!" << endl;
    }

        else
        {
            cout << "Goodbye!" << endl;
            exit(0);
        }

cout << "Roll The Dice" << endl;
cout << "Type (roll) To Roll The Dice" << endl;
cin >> roll;
    if (roll == "roll")
    {
        cout << "You've Rolled A " << endl;
    }

        else
        {
            cout << "Try Again!" << endl;
            exit(0);
        }

    srand(time(0));
        for (int x = 1; x<=1; x++)
        {
            cout << 1+(rand()%12) << endl;
        }


}
If you want to press any key and then enter you could just have
1
2
3
4
5
6
7
8
9
cin >> roll;

		cout << "You've Rolled A " << endl;
		
		srand(time(0));
        for (int x = 1; x<=1; x++)
        {
            cout << 1+(rand()%12) << endl;
        }

Other than that, I'm not sure of a way to press any key to continue
Topic archived. No new replies allowed.