Created
May 28, 2013 04:08
-
-
Save kdmkdmkdm/5660472 to your computer and use it in GitHub Desktop.
cards
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// #include "stdafx.h" seems to be something I have to include every time... | |
#include "stdafx.h" | |
#include <stdio.h> | |
#include <stdlib.h> | |
int main() | |
{ | |
char card_name[3]; | |
puts("Enter a card name: "); | |
// changed scanf to scanf_s on the following line | |
scanf_s("%2", 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; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment