Display random number computer chooses

What I'm trying to do is build a rock paper scissors game and I'm stuck at generating a computer choice (rock paper scissors) and displaying the number of that choice. That's all I'm trying to do at the moment.
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
  #include <iostream>
#include <stdlib.h>
#include <time.h>

using namespace std;

int menu();
int getCompChoice();
int getUserChoice();
int compChoice();

int main()
{
    int compChoice;
    cout << compChoice << endl;
}
int menu()
{
    cout << "Rock Paper Scissors Lizard Spock Game" << endl;
    cout << "1. Rock" << endl;
    cout << "2. Paper" << endl;
    cout << "3. Scissors" << endl;
    cout << "4. Lizard" << endl;
    cout << "5. Spock" << endl;
}
int compChoice()
{
    srand (time(0));
    rand() % 5 + 1;
}
I caught a couple of errors. Here is the fixed code:
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
  #include <iostream>
#include <stdlib.h>
#include <time.h>

using namespace std;

int menu();
int getCompChoice();
int getUserChoice();
int compChoice();

int main()
{
    int comphoice;
    cout << compChoice() << endl;
}
int menu()
{
    cout << "Rock Paper Scissors Lizard Spock Game" << endl;
    cout << "1. Rock" << endl;
    cout << "2. Paper" << endl;
    cout << "3. Scissors" << endl;
    cout << "4. Lizard" << endl;
    cout << "5. Spock" << endl;
}
int compChoice()
{
    srand (time(0));
    return rand() % 5 + 1;
}



Please look at the changes carefully to understand what was wrong.
Ahh I realized what was wrong. I don't even need the int comphoice;. I put it in there for a reason before I started messing with it to make it work and I don't need it anymore.
Topic archived. No new replies allowed.