There are several issues (including
kooth's post about
next_card()
):
You've peppered your code with semicolons that are not required! You only need a semicolon ("
;") after a statement. You do not require them after:
-
while
loops
-
function
/
method
definitions
-
if
&
else
statements
So you can start by getting rid of all the offending semicolons.
The code here (on line 20 & 26):
while(next_card[d])
does not make sense. You are trying to invoke a
function as if it were an
array. You should pass the parameters inside
round brackets like this:
next_card(d)
. Also the function prototype for
next_card specifies the return type
int
but you do not return a value.
On line 38 you have:
next_card();
. When you defined the function
next_card(int cards_remaining)
on line 17, you specify the parameter
int cards_remaining
. You cannot call this function without a parameter of type
int
because of the way you have defined it. You could
overload the function, but I don't think that is what you intended (
I'll provide a link at the end).
On line 70, in the condition part of your
for
loop, you misspelt
player_num
as
playernum
. Similarly on line 72 you misspelt
draw_card
as
draw_a_card
.
The definition of
play_again(char again)
appears at line 115 but you invoke the function on line 100, 105 & 110. This is an error as functions that are used must be defined above where they are called. Also you call play_again without passing any parameters, after specifying that
play_again
will take a
char
as the parameter.
Similarly you've called the function
game
inside of the
play_again
function, so it won't compile when you place it above the function
game
.
You can remedy this by using
function prototypes at the top of your code (
I'll provide a link). A function prototype tells the compiler that at some point in your code you are going to define a function with the prototype specified. For example:
1 2 3 4 5 6 7 8
|
int function(int param1); //function prototype
//your code
int function(int param1) //function definition
{
//function body
}
|
On line 89 you forgot to put a semicolon after
dealer_draw_card
.
Also some of your variables are used without initialisation.
Finally your application lacks a
main()
function. Every C++ program (
I think there might be a few exceptions),
needs a main function. As it is the first entry point for all C++ applications.
Here are the links as promised:
Overloading Functions:
http://en.wikipedia.org/wiki/Function_overloading
Function Prototypes:
http://en.wikipedia.org/wiki/Function_prototype
Whoo, I think I've written a small novel.