int main(void)
{
char faceValue[2];
char suitValue[2];
//User enters the value of their hole cards.
setCardFaceValue(faceValue);
setCardSuitValue(suitValue);
for(int i=0;i<2;i++)
printf("Element %i: %c %c\n",i,faceValue[i],suitValue[i]);
return 0;
}
void setCardFaceValue(char* face)
{
char card[2][20] = {"left card:","right card:"};
for(int i=0;i<2;i++) {
printf("Enter face value for ");
for(int x=0;x<19;x++) {
printf("%c",card[i][x]);
if(card[i][x] == ':') {
fgets(&face[i],3,stdin);
}
}
}
}
void setCardSuitValue(char* suit)
{
char card[2][20] = {"left card:","right card:"};
for(int i=0;i<2;i++) {
printf("Enter suit value for ");
for(int x=0;x<19;x++) {
printf("%c",card[i][x]);
if(card[i][x] == ':') {
fgets(&suit[i],3,stdin);
}
}
}
}
Here is the output:
Click Here
The value entered for the first question should be assigned to element 0 in the faceValue array.
The value entered for the second question should be assigned to element 1 in the faceValue array.
The value entered for the third question should be assigned to element 0 in the suitValue array.
The value entered for the fourth question sholuld be assigned to element 1 in the suitValue array.
This does not seem to happen, they get jumbled up and I know it has somethiing to do with the buffer, but I don't know what, any insight would be helpful.