"Too Few Argument to Function"

I seem to have this error message "Too few arguments to function `void draw_a_card(int&, int&, int&)" but it seem there is enough. I called the function around line 72.

Thank you

Heres my 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
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
#include <cstdlib>
#include <iostream>
#include <time.h>
#include <math.h>
using namespace std;
string suits[4] = {"Hearts", "Diamonds", "Spades", "Clubs"};
string ranks[13] = {"Ace", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine", "Ten", "Jack", "Queen", "King"};
int card_drawn[52];

int cards_remaining = 52;

//This function finds the Nth element of card_drawn and skipping over all those those elements already set to true.
int select_next_available(int n) {
    int i = 0;
    //at the beginning of deck, skip past cards already drawn.
    while (card_drawn[i])
    i++;
    while (n-- > 0) { //do the following n times:
    i++; //advanced next card
    while (card_drawn[i]) //skip past cards
          i++;// already drawn.
    }//end while
    card_drawn[i] = true; // note card to be drawn
    return i; //return this number
} //end select_next_available function

int rand_0toN1(int n) {
return rand() % n;
} //end function

void draw_a_card(int &r, int &s, int &a){
int n, card;
n = rand_0toN1(cards_remaining--); //get random number from the remaining card availble
card = select_next_available(n);
r = card % 13; //random index (0 to 12) into rank array
s = card % 4; //random index (0 to 3) into suits array
cout << ranks[r] << " of " << suits[s] << endl;
a = a + r + 1;
cout << "Total: " << a << endl;




} //end draw a card

int main ()
{
int n, c, i;
int card, type, value;
string a;
// n == 2; This is a comparison operator ==
n = 2;
c = 1;
srand(time(NULL));


cout << "Blackjack" << endl;
cout << "Play (Y/N)" << endl;
cin >> a;
if (a == "y" || a == "Y")
{
for(i = 0; i < n; i++) // 0, 1, break gives you two iterations
draw_a_card(card,type);
}
while (1)
{
cout << "Hit?" << endl;
cin >> a;
if (a == "y" || a == "Y")
{
for (i = 0; i < c; i++)
draw_a_card(card, type, value);
}
else 
cout << value << endl;
}
system("PAUSE");
return 0;
}//end main  

Last edited on
You mean line 63, right?

-Albatross
Oops I notice I am missing one variable in that one. Well I am trying to get the sum of the card from the draw a card function. But now I am getting some bizarre number. Help would be appreciated in helping me solve this problem.
I get no bizarre numbers from this when I plug in value to that function. What I DO get is an infinite loop. You'll want to break that loop at some point, such as when value exceeds 20 or when the person don't want to be given any more cards.

-Albatross
Bizarre numbers, as in... For example 1039654 instead of, 11 or something in that range?
closed account (z05DSL3A)
You need to initialise your variables.

int card, type, value; =>int card(0), type(0), value(0);


P.S. You should also explicitly include needed headers, you are using std::string you should #include <string>.
Topic archived. No new replies allowed.