Original Post
This code produces 3 parse errors:
c:\my documents\2 card draw source.c: In function `playerCards'':
c:\my documents\2 card draw source.c:146: parse error before `dealerCards''
c:\my documents\2 card draw source.c:187: parse error before `int''
c:\my documents\2 card draw source.c:223: parse error at end of input
Why does it do this? I have tweaked and fiddled but it still doesn''t work!
Thanks for your time, it''s greatly appreciated.
Graham
#include
#include
#include
#include
#include
#define Jack 11
#define Queen 12
#define King 13
char suit[10];
int dnumCard1;
int dnumCard2;
int cards = 13;
char * dsuitname[10];
char * dsuitnameb[10];
int numCard1;
int numCard2;
int suits = 4;
int suita;
int suitb;
int dsuita;
int dsuitb;
char * suitname[10];
char * suitnameb[10];
char name[30];
int total;
int dtotal;
int error = 0;
int bet;
int bank = 220;
int msg;
int wime;
main()
{
while (bank > 0)
{
welcome();
clear();
flumpy();
clear();
playerCards();
dealerCards();
result();
}
system("PAUSE");
return 0;
}
welcome()
{
printf("Hello and Welcome to 2 Card Draw!!\n");
printf("Please enter your name: ");
scanf(" %s", &name);
printf("\nThank You.\n");
printf("We hope you enjoy your evening, %s!\n", name);
system("PAUSE");
error = 1;
return 0;
}
clear()
{
int clear;
for(clear = 0; clear < 25; clear++)
{
printf("\n");
return 0;
}
}
flumpy()
{
printf("It''s risky this two card draw. You have $220.\n");
printf("You double your dosh if you win.\n");
printf("Dealer wins if the cards value is equal\n");
bank = 220;
printf("Place you bet: ");
scanf(" %d", &bet);
while(bet >> bank)
{
printf("\nYou have entered an illegal amount.\n Please re-enter your amount or press x to exit.");
scanf(" %d", bet);
if(bet == ''x'')
{
exit(1);
}
bank -= bet;
printf("You have %d left in the bank\n", bank);
system("PAUSE");
return 0;
}
}
playerCards()
{
numCard1 = (rand() % 13);
numCard2 = (rand() % 13);
if (numCard1 == numCard2)
{
numCard2 -= 1;
}
do
{suita = (rand() % (suits));
switch(suita)
{case (1) : strcpy((char *)suitname,"Diamonds");
break;
case (2) : strcpy((char *)suitname,"Hearts");
break;
case (3) : strcpy((char *)suitname,"Spades");
break;
default : strcpy((char *)suitname,"Clubs");
break;
} ;
do
{suitb = (rand() % (suits));
switch(suitb)
{case (1) : strcpy((char *)suitnameb,"Diamonds");
break;
case (2) : strcpy((char *)suitnameb,"Hearts");
break;
case (3) : strcpy((char *)suitnameb,"Spades");
break;
default : strcpy((char *)suitnameb,"Clubs");
break;
};
return 0;
}
dealerCards();
{
dnumCard1 = (rand() % (cards));
dnumCard2 = (rand() % (cards));
if (dnumCard1 == dnumCard2)
{
dnumCard2 -= 1;
}
do
{suita = (rand() % (suits));
switch(suita)
{case (1) : strcpy((char *)suitname,"Diamonds");
break;
case (2) : strcpy((char *)suitname,"Hearts");
break;
case (3) : strcpy((char *)suitname,"Spades");
break;
default : strcpy((char *)suitname,"Clubs");
break;
};
do
{suitb = (rand() % (suits));
switch(suitb)
{case (1) : strcpy((char *)suitnameb,"Diamonds");
break;
case (2) : strcpy((char *)suitnameb,"Hearts");
break;
case (3) : strcpy((char *)suitnameb,"Spades");
break;
default : strcpy((char *)suitnameb,"Clubs");
break;
};
return 0;
;
int result(int)
{
printf("\nWell, here comes the moment of truth...\n");
sleep(2);
printf("You got the %s of %s and the %s of %s.\n", numCard1, suitname, numCard2, suitnameb);
printf("The dealer got %s of %s and the %s of %s\n", dnumCard1, dsuitname,dnumCard2, dsuitnameb);
printf("Hang on, that means....\n");
total = numCard1 + numCard2;
dtotal = dnumCard1 + dnumCard2;
sleep(2);
printf("You got %d and dealer got %d. ", total, dtotal);
if (total >> dtotal)
{
bank += bet;
printf("You win!!! You now have $%d\a", bank);
system("PAUSE");
return 0;
}
else
{
bank -= bet;
printf("You lose. Your balance now rests on $%d.\n Press 1 to exit.", bank);
msg = getchar();
if (msg == 1)
{
exit(1);
}
if (bank << 0)
{
printf("You are in minus figures.");
system("PAUSE");
exit(1);
};
};
}