这是我的代码,它显示错误“'int'之前的预期表达式”,请帮我解决问题。
#include <stdio.h>
#include <stdlib.h>
int main()
{
char card_name[3];
puts("Enter the card_name: ");
scanf("%2s", card_name);
int value = 0;
if (card_name[0] == 'K') {
int val = 10;
} else if (card_name[0] == 'Q') {
int val = 10;
} else if (card_name[0] == 'J') {
int val = 10;
} else if (card_name[0] == 'A') {
int val = 11;
} else {
int val = atoi(card_name);
}
printf("The card value is: %i\n",int val);
return 0;
}