[solved]"Too many arguments" error

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
105
106
107
108
#include <iostream>
#include <cstdlib>
#include <ctime>
#include <cctype>
using namespace std;
int redo();
int main(){
    int cardone, cardtwo, cardthr, cardfor, cardfiv;
    int num_of_hits = 0;
    char h_or_s, doag;
    bool a = true;
    bool b;
    srand( (unsigned)time(0) );
    cout << "Welcome to Console Blackjack 1.1! You can hit three times total. ";
    do{
    num_of_hits = 0;
    cardone = (rand()%13) + 1;
    cardtwo = (rand()%13) + 1;
    cardthr = (rand()%13) + 1;
    cardfor = (rand()%13) + 1;
    cardfiv = (rand()%13) + 1;
    if(cardone > 10)
    cardone = 10;
    if(cardtwo > 10)
    cardtwo = 10;
    if(cardthr > 10)
    cardthr = 10;
    if(cardfor > 10)
    cardfor = 10;
    if(cardfiv > 10)
    cardfiv = 10;
    cout << "Your card values are: " << cardone << " and " << cardtwo << ".\n";
    if(cardone+cardtwo==21){
    cout << "21!!!!!!\n";
    redo(b);}
    else if(cardone + cardtwo > 21){
    cout << "BUST!\n";
    redo(b);
}else
    cout << "Hit or stay? [h/s] ";
    do{
    cin >> h_or_s;
    switch(h_or_s){
         case 'h':case 'H':
              num_of_hits++;
              if(num_of_hits == 1){
              cout << "Your next card is " << cardthr << " and your total value is " << cardone+cardtwo+cardthr;
              if(cardone+cardtwo+cardthr==21){
              cout << ". You win!!!!\n";
              redo();
              }else if(cardone+cardtwo+cardthr>21){
              cout << ". BUST!\n";
              redo();
              cout << ". Hit or stay? ";
              continue;}}
              if(num_of_hits == 2){
              cout << "Your next card is " << cardfor << " and your total value is " << cardone+cardtwo+cardthr+cardfor;
              if(cardone+cardtwo+cardthr+cardfor==21){
              cout << ". You win!!!!\n";
              redo(b);
              }else if(cardone+cardtwo+cardthr+cardfor>21){
              cout << ". BUST!\n";
              redo(b);
              }else{
              cout << ". Hit or stay? ";
              continue;}}
              if(num_of_hits == 3){
              a = false;
              cout << "Your next card is " << cardfiv << " and your total value is " << cardone+cardtwo+cardthr+cardfor+cardfiv;
              if(cardone+cardtwo+cardthr+cardfor+cardfiv==21){
              cout << ". You win!!!!\n";
              cout << "Restart? [y/n] ";
              redo(b);
              }else if(cardone+cardtwo+cardthr+cardfor+cardfiv>21){
              cout << ". BUST!\n";
              redo(b);  
              }else
              cout << ".\nYour cards were worth " << cardone+cardtwo+cardthr+cardfor+cardfiv << ". Thanks for playing! ";
              }break;
              
              case 's':case 'S':
              a = false;
              if(num_of_hits == 0)
              cout << "Your cards in total were worth " << cardone+cardtwo << ". Thanks for playing! ";
              else if(num_of_hits == 1)
              cout << "Your cards in total were worth " << cardone+cardtwo+cardthr << ". Thanks for playing! ";
              else if(num_of_hits == 2)
              cout << "Your cards in total were worth " << cardone+cardtwo+cardthr+cardfor << ". Thanks for playing! ";
              break;
         }}while(a);
    redo(b);
    }while(b);
    system("pause");
    return 0;
}
     int redo(){
         char doag;
         cout << "Restart? [y/n] ";
         cin >> doag;
         switch(doag){
         case 'y':case 'Y':
         main();
         break;
         case 'n':case 'N':
         system("pause");
         return 0;
         break;
         }}

The errors occur whenever I try to call the redo function. I've tried moving it around and all, but I don't think that's the problem. Any ideas?
Last edited on
Your redo function doesn't take any parameters.
You probably want to assign to 'b' the return value of redo();
So you should use: b = redo();

In the redo() function you have a "return 0;" This is the return from you function and not the return of the main to exit the program. Instead of calling back main you should us "return 1;" and at the beginning of the do-while loop to clear all the values again.
Last edited on
Thanks!

I posted a modified version in the Lounge. Enjoy!
I tried to lunch the one you have in lounge but i have the following errors and warnings:

1>.\main.cpp(36) : error C2065: 'o_or_e' : undeclared identifier
1>.\main.cpp(37) : error C2065: 'o_or_e' : undeclared identifier
1>.\main.cpp(38) : warning C4553: '==' : operator has no effect; did you intend '='?
1>.\main.cpp(40) : warning C4553: '==' : operator has no effect; did you intend '='?
1>.\main.cpp(43) : error C2065: 'o_or_e' : undeclared identifier
1>.\main.cpp(44) : error C2065: 'o_or_e' : undeclared identifier
1>.\main.cpp(45) : warning C4553: '==' : operator has no effect; did you intend '='?
1>.\main.cpp(47) : warning C4553: '==' : operator has no effect; did you intend '='?
1>.\main.cpp(50) : warning C4800: 'int' : forcing value to bool 'true' or 'false' (performance warning)
1>.\main.cpp(53) : warning C4800: 'int' : forcing value to bool 'true' or 'false' (performance warning)
1>.\main.cpp(66) : error C2065: 'o_or_e' : undeclared identifier
1>.\main.cpp(67) : error C2065: 'o_or_e' : undeclared identifier
1>.\main.cpp(68) : warning C4553: '==' : operator has no effect; did you intend '='?
1>.\main.cpp(70) : warning C4553: '==' : operator has no effect; did you intend '='?
1>.\main.cpp(75) : warning C4800: 'int' : forcing value to bool 'true' or 'false' (performance warning)
1>.\main.cpp(78) : warning C4800: 'int' : forcing value to bool 'true' or 'false' (performance warning)
1>.\main.cpp(88) : error C2065: 'o_or_e' : undeclared identifier
1>.\main.cpp(89) : error C2065: 'o_or_e' : undeclared identifier
1>.\main.cpp(90) : warning C4553: '==' : operator has no effect; did you intend '='?
1>.\main.cpp(92) : warning C4553: '==' : operator has no effect; did you intend '='?
1>.\main.cpp(97) : warning C4800: 'int' : forcing value to bool 'true' or 'false' (performance warning)
1>.\main.cpp(100) : warning C4800: 'int' : forcing value to bool 'true' or 'false' (performance warning)
1>.\main.cpp(113) : error C2065: 'o_or_e' : undeclared identifier
1>.\main.cpp(114) : error C2065: 'o_or_e' : undeclared identifier
1>.\main.cpp(115) : warning C4553: '==' : operator has no effect; did you intend '='?
1>.\main.cpp(117) : warning C4553: '==' : operator has no effect; did you intend '='?
1>.\main.cpp(122) : warning C4800: 'int' : forcing value to bool 'true' or 'false' (performance warning)
1>.\main.cpp(126) : warning C4800: 'int' : forcing value to bool 'true' or 'false' (performance warning)
1>.\main.cpp(150) : warning C4800: 'int' : forcing value to bool 'true' or 'false' (performance warning)
Hmmm....
Fixed it! Enjoy...now!
Last edited on
Topic archived. No new replies allowed.