I have been reading the head first book about C and I am having a bit of problem with one of the given examples. The example is shown talking about a "code magnet" for a game of blackjack. I went to try out the code and tried to make my own tweaks to it and i don't understand the "errors" I am getting.
Here is the code I have been playing around with:
#include <stdio.h>
#include <stdlib.h>
int main()
{
char card_name[3];
puts("Enter the card name: ");
scanf("&2s", card_name);
int val = 0;
if (card_name[0] == 'K')
{
val = 10;
}
else if (card_name[0] == 'Q')
{
val = 10;
}
else if (card_name[0] == 'J')
{
val = 10;
}
else if (card_name[0] == 'A')
{
val = 11;
}
else
{
val = atoi(card_name);
}
printf("The card value is: %i\n", val);
return 0;
}
Someone, please explain to me what I am getting wrong. I am a bit lost on what my mistakes are. I am new to C for the heads up. (I am only about 3-5 days experienced).