help me with functions

in the race (placebet , userResponse) function the compiler is telling me that i have too many arguments. and i am confused. can someone edit and run this code for me please because i am confused and i cannot run it :(

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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
  #include <iostream>
#include <cstdlib>
#include <windows.h>
#include <ctime>

void race (void);
int menu (void);
int placebet(void);
void init (void);

/*declaring variables*/
int money = 200;

using namespace std;
int main (void)
{
init();
int userResponse;

cout<<"welcome to the snail races !";

while (userResponse == menu());

switch (userResponse)
{
    case 1:
    case 2:
    case 3:
        ::money+=
        race (placebet, userResponse);
        break;
    case 4:
        /*the user did not bet*/
        race();
        break;
}
}
return 0;
}
int menu (void)
{
    std::cout;
    std::cin;

cout<<"welcome to the snail races !!!"<<endl;
cout<<"you have "<<money<<" dollars"<<endl;

do {
        cout<<"1) Bet on snail 1"<<endl
            <<"2) bet on snail 2"<<endl
            <<"3) bet on snail 3"<<endl
            <<"4) just watch"<<endl
            <<"0) leave the races"<<endl;

cin>>userResponse;
}while (userResponse < 0 && userResponse > 4);
return userResponse;
}

}
/*if the user chose to bet money*/
int race (int money , int userResponse)
{
    std::cout;
    std::cin;

cout<<"and the snails are off ! look at them go ! "<<endl;
int winner = rand () % 3+1;
cout<<"the winner is snail "<<winner<<endl;

if (winner == userResponse)
{
    cout<<"yeah ! you win ! "<<endl;
    return money * 2;
}
}
/*seeding the generator for the main function.*/
void init (void);
{
    std::time;
    std::rand;
    std::srand;
    srand (time (NULL));
}
int placebet (int userResponse)
{
    using std::cout;
    using std::cin;
    int betAmount;

cout<<"snail "<<userResponse<<" is a good choice"<<endl;
cout<<"how much would you like to bet on you snail"
    <<userResponse<<" ? ";

cin>>betAmount;
return betAmount;

}
/*if they are just watching the race */
void race (void)
{
    race (0,0);
}
You need to make sure that function prototypes, function definitions and the use of the function in the program all agree in terms of the numbers and types of parameters sent.

A couple of other things...

I'm not sure what you're trying to do with this line? There is no valid value for userResponse when you first try to compare it to the result returned from the menu function.

while (userResponse == menu());

This is never going to be true - the same number can't both be less than zero and greater than 4.

}while (userResponse < 0 && userResponse > 4);
Topic archived. No new replies allowed.