The main problem is that you try to define functions within another function (the main() function, in this case), as MaidenIndigo pointed out correctly. Thus, you must move them out. The rest have been some general syntax errors which you would probably have been able to fix yourself, but I wanted to make sure the code at least compiles so I fixed them, too. These fixes are what seems to be appropriate after only glancing at it, but might not enable the code to actually work, which I couldn\'t test for lack of the remaining code. :)
Anyway, here is a compiling version:
// A program that plays Black Jack with you.
#include
//#include
#include
using namespace std;
#define SCORE_SYSTEM scoreSystem(pickedCard, score, score2)
#define CHECK check(pickedCard, usedCards, r)
#define DEAL deal(deck, usedCards, r, playerScore, playerScore2, dealerScore, dealerScore2, score, score2)
int scoreSystem(int pickedCard, int score, int score2) { //Scoring algorithm [begining]
score = 1, score2 = 1; //Set scores 1&2
if(pickedCard >= 48 && pickedCard <= 51) score = 1, score2 = 11; //If ace is selected
else { //If ace is not selected
for(int a=0, b=0; b<48;) {
score++, score2++;
b = a+3;
if(pickedCard >= a && pickedCard <= b) break;
a += 4;
}
}
return score, score2;
} // Scoring algorithm [end]
int check(int pickedCard, int usedCards[], int r) { //Checking [begining]
for(int i=0; i<52; i++) {
if(pickedCard == usedCards[ i ]) {r=1; break;} // if card was used
else { // if card was not used
r=0;
}
}
for (int x=0; x<52; x++) { // Keep Track of picked cards.
if(x==99) {usedCards[x]=pickedCard; break;}
else;
}
return r;
}// Checking [end]
int deal(int deck[], int usedCards[], int r, int playerScore, int playerScore2, //Deal hands
int dealerScore, int dealerScore2, int score, int score2) { //[begining]
int pickedCard;
for(int i=0;i<=2;){ //Deal to player
pickedCard = rand()%51;
CHECK; // Check if card was already picked
if(r) continue;
else;
SCORE_SYSTEM;
i++;
playerScore += score;
playerScore2 += score2;
}
for(int x=0;x<=2;){ //Deal to dealer
pickedCard = rand()%51;
CHECK; // Check if card was already picked
if(r) continue;
else SCORE_SYSTEM; x++;
dealerScore += score; // Add to player score
dealerScore2 += score2;
}
return playerScore, playerScore2, dealerScore, dealerScore2;
}
int main()
{
int cash, bet, pot;
int score, score2;
int playerScore = 0, playerScore2 = 0;
int dealerScore = 0, dealerScore2 = 0;
int pickedCard;
int deck[51];
int usedCards[51];
int r;
char question[15];
for(int i=0; i<52; i++) deck[ i ]=i; //Load up deck
cout << \"******************************\\n\";
cout << \"*Game: BlackJack *\\n\"; // Header
cout << \"*Version: Alpha Test *\\n\";
cout << \"*Developer: Egor Poblaguev*\\n\";
cout << \"******************************\\n\\n\\n\";
for(;;) { // Begin Game
srand(GetTickCount()); //Generate random seed
for(int i=0; i<52; i++) usedCards[ i ]=99; // Set usedCards to default
cash = 100; // Set initial cash
pot = bet * 2; // Define pot
cout << \"*****************\\n\";
cout << \"Total cash: \" << cash << \"\\n\";
cout << \"Place bet: \";
cin >> bet;
cout << \"*****************\\n\\n\";
DEAL; // Deal hands
do { // Player\'s Turn
cout << \"*************************\\n\";
cout << \"Your Score: \" << playerScore << \" || \" << playerScore2 << \"\\n\"; // Display Score
cout << \"Current Pot: \" << pot << \"\\n\"; // Display current pot
cout << \"Draw again? (\'y\' or \'n\') \";
gets(question);
cout << \"\\n*************************\\n\";
if(strcmp(question,\"y\")==0) {
for(;;){ //Deal to player
pickedCard = rand()%51;
CHECK; // Check if card was already picked
if(r) continue; //If card was used
else SCORE_SYSTEM;
playerScore += score;
playerScore2 += score2;
break;
}
}
else;
}while(strcmp(question, \"n\")!=0);
}
}
Output of a diff (only to show what I changed)
9c9
< //#include
---
> #include
22c22,47
< int scoreSystem(int pickedCard, int score, int score2) { //Scoring algorithm [begining]
---
>
> int main()
>
> {
>
> int cash, bet, pot;
>
> int score, score2;
>
> int playerScore = 0, playerScore2 = 0;
>
> int dealerScore = 0, dealerScore2 = 0;
>
> int pickedCard;
>
> int deck[51];
>
> int usedCards[51];
>
> int r;
>
> char question[15];
>
>
>
> int scoreSystem(pickedCard, score, score2) { //Scoring algorithm [begining]
30c55
< for(int a=0, b=0; b<48;) {
---
> for(int a=0, int b=0; b<48;) {
50c75
< int check(int pickedCard, int usedCards[], int r) { //Checking [begining]
---
> int check(pickedCard, usedCards, r) { //Checking [begining]
66c91
< if(x==99) {usedCards[x]=pickedCard; break;}
---
> if(x==99) {usedCards[ i ]=pickedCard; break;}
77c102
< int deal(int deck[], int usedCards[], int r, int playerScore, int playerScore2, //Deal hands
---
> int deal(deck, usedCards, r, playerScore, playerScore2, //Deal hands
79c104
< int dealerScore, int dealerScore2, int score, int score2) { //[begining]
---
> dealerScore, dealerScore2, score, score2) { //[begining]
81d105
< int pickedCard;
125,152d148
< int main()
<
< {
<
< int cash, bet, pot;
<
< int score, score2;
<
< int playerScore = 0, playerScore2 = 0;
<
< int dealerScore = 0, dealerScore2 = 0;
<
< int pickedCard;
<
< int deck[51];
<
< int usedCards[51];
<
< int r;
<
< char question[15];
<
<
<
<
<
<
<
214c210
< cout << \"\\n*************************\\n\";
---
> cout << \"\\n*************************\\n;
216c212
< if(strcmp(question,\"y\")==0) {
---
> if(question == \'y\') {
240c236
< }while(strcmp(question, \"n\")!=0);
---
> }while(question != \'n\');
Also, MaidenIndigo is correct in saying that the use of a string to hold a single letter is a waste, but there are some other things that I\'d avoid (break statements, for example), and maybe you have plans with that string?
Just a few hints:
The use of macros for function calls is not a good idea IMO, because it takes away the freedom to use different parameters for each call.
Also, you should #define all constants that will be used more than once (like the deck size), so that you won\'t have to change many occurances, likely missing one, causing debugging pain to yourself.
Anyway, hope this helps!
Edit: the forum should really disable smilies in [ code ] [ / code ] statements...
Edit 2: Also, it is highly likely that \"return var1,var2;\" isn`t going to do what you want (return two values): you will need references or pointers for that. The way it is now, only the rightmost value will be returned, the other(s) discarded.
Thus, you need to change your function to something like this:
int scoreSystem(int pickedCard, int &score, int &score2)
This will make the assignments inside the function work on the variable in the calling function (main()), instead on a copy, as is the default behaviour.
Thus, you don\'t need the return value for that and can either change it ti void or use it for something else.
edit 3: added spaces in array subscripts like [ i ] so the board won\'t interprete them as as italic formatting.