Okay, so before we address your question. A few very important things:
-You
must not be using goto. I really cannot stress this enough. It makes code difficult to read and difficult to debug, which will be a pain for you in future (if not already) and is a pain for people on forums like this trying to help.
-It would be
greatly helpful if you
comment your code, for me, for you, for everyone.
-A smaller point. You do not need <stdio> and <ctime> is the proper version of the library to use, rather than <time.h>.
-It would also help greatly if you used consistent indentation.
General advice aside now, onto your question. . .
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
|
if(*(card+i)==11)
{
cout<<"J"<<" ";
*(card+i)=10;
}
else if((*card+i)==12)
{
cout<<"Q"<<" ";
*(card+i)=10;
}
else if((*card+i)==13)
{
cout<<"K"<<" ";
*(card+i)=10;
}
|
This part of your code displays the appropriate char if the card is J, Q or K, however...
1 2 3
|
*(card+i)=rand()%13+1;
filtercards(card);
cout <<*(card+i)<<" ";
|
This line following the function call spits out the number regardless of if J, Q or K was already displayed.
Also, looking back at this piece of code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
|
if(*(card+i)==11)
{
cout<<"J"<<" ";
*(card+i)=10;
}
else if((*card+i)==12)
{
cout<<"Q"<<" ";
*(card+i)=10;
}
else if((*card+i)==13)
{
cout<<"K"<<" ";
*(card+i)=10;
}
|
This is going through J, Q and K if you get a J and through Q and K if you get a queen.
Or basically, I don't think this method is working and it seems confusing as hell, so my suggestion is to use a different method to display your cards and work out the sums. One suggestion is storing cards in an array and converting 11,12 and 13 to 10 in any sum function and J,Q or K (as appropriate) in any display function.