{"id":3261,"date":"2025-04-10T18:50:06","date_gmt":"2025-04-10T09:50:06","guid":{"rendered":"https:\/\/h4ck.kr\/?p=3261"},"modified":"2025-04-10T18:50:08","modified_gmt":"2025-04-10T09:50:08","slug":"blackjack","status":"publish","type":"post","link":"https:\/\/h4ck.kr\/?p=3261","title":{"rendered":"blackjack"},"content":{"rendered":"\n<h1 class=\"wp-block-heading\">Description<\/h1>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"raw\" data-enlighter-theme=\"dracula\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">Hey! check out this C implementation of blackjack game!\nI found it online\n* &lt;http:\/\/cboard.cprogramming.com\/c-programming\/114023-simple-blackjack-program.html>\n\nI like to give my flags to millionares.\nhow much money you got?\n\nssh blackjack@pwnable.kr -p2222 (pw:guest)<\/pre>\n\n\n\n<h1 class=\"wp-block-heading\">Source Code<\/h1>\n\n\n\n<ul class=\"wp-block-list\">\n<li>blackjack.c<\/li>\n<\/ul>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"c\" data-enlighter-theme=\"dracula\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\/\/ Programmer: Vladislav Shulman\n\/\/ Final Project\n\/\/ Blackjack\n \n\/\/ Feel free to use any and all parts of this program and claim it as your own work\n \n\/\/FINAL DRAFT\n \n#include &lt;stdlib.h>\n#include &lt;stdio.h>\n#include &lt;math.h>\n#include &lt;string.h>\n#include &lt;time.h>                \/\/Used for srand((unsigned) time(NULL)) command\n \n#define spade 'S'                 \/\/Used to print spade symbol\n#define club 'C'                  \/\/Used to print club symbol\n#define diamond 'D'               \/\/Used to print diamond symbol\n#define heart 'H'                 \/\/Used to print heart symbol\n#define RESULTS \"Blackjack.txt\"  \/\/File name is Blackjack\n \n\/\/Global Variables\nint k;\nint l;\nint d;\nint won;\nint loss;\nint cash = 500;\nint bet;\nint random_card;\nint player_total=0;\nint dealer_total;\n \n\/\/Function Prototypes\nint clubcard();      \/\/Displays Club Card Image\nint diamondcard();   \/\/Displays Diamond Card Image\nint heartcard();     \/\/Displays Heart Card Image\nint spadecard();     \/\/Displays Spade Card Image\nint randcard();      \/\/Generates random card\nint betting();       \/\/Asks user amount to bet\nvoid asktitle();     \/\/Asks user to continue\nvoid rules();        \/\/Prints \"Rules of Vlad's Blackjack\" menu\nvoid play();         \/\/Plays game\nvoid dealer();       \/\/Function to play for dealer AI\nvoid stay();         \/\/Function for when user selects 'Stay'\nvoid cash_test();    \/\/Test for if user has cash remaining in purse\nvoid askover();      \/\/Asks if user wants to continue playing\nvoid fileresults();  \/\/Prints results into Blackjack.txt file in program directory\n \n\/\/Main Function\nint main(void)\n{\n    setvbuf(stdout, 0, _IONBF, 0);\n    setvbuf(stdin, 0, _IOLBF, 0);\n\n    int choice1;\n    printf(\"\\n\");\n    printf(\"\\n\");\n    printf(\"\\n\");\n    printf(\"\\n              222                111                            \");\n    printf(\"\\n            222 222            11111                              \");\n    printf(\"\\n           222   222          11 111                            \"); \n    printf(\"\\n                222              111                               \"); \n    printf(\"\\n               222               111                           \");   \n    printf(\"\\n\");\n    printf(\"\\n%c%c%c%c%c     %c%c            %c%c         %c%c%c%c%c    %c    %c                \", club, club, club, club, club, spade, spade, diamond, diamond, heart, heart, heart, heart, heart, club, club);  \n    printf(\"\\n%c    %c    %c%c           %c  %c       %c     %c   %c   %c              \", club, club, spade, spade, diamond, diamond, heart, heart, club, club);            \n    printf(\"\\n%c    %c    %c%c          %c    %c     %c          %c  %c               \", club, club, spade, spade, diamond, diamond, heart, club, club);                        \n    printf(\"\\n%c%c%c%c%c     %c%c          %c %c%c %c     %c          %c %c              \", club, club, club, club, club, spade, spade, diamond, diamond, diamond, diamond, heart, club, club);      \n    printf(\"\\n%c    %c    %c%c         %c %c%c%c%c %c    %c          %c%c %c             \", club, club, spade, spade, diamond, diamond, diamond, diamond, diamond, diamond, heart, club, club, club);                       \n    printf(\"\\n%c     %c   %c%c         %c      %c    %c          %c   %c               \", club, club, spade, spade, diamond, diamond, heart, club, club);                                         \n    printf(\"\\n%c     %c   %c%c        %c        %c    %c     %c   %c    %c             \", club, club, spade, spade, diamond, diamond, heart, heart, club, club);                                                            \n    printf(\"\\n%c%c%c%c%c%c    %c%c%c%c%c%c%c   %c        %c     %c%c%c%c%c    %c     %c            \", club, club, club, club, club, club, spade, spade, spade, spade, spade, spade, spade, diamond, diamond, heart, heart, heart, heart, heart, club, club);                                                                                     \n    printf(\"\\n\");     \n    printf(\"\\n                        21                                   \");\n     \n    printf(\"\\n     %c%c%c%c%c%c%c%c      %c%c         %c%c%c%c%c    %c    %c                \", diamond, diamond, diamond, diamond, diamond, diamond, diamond, diamond, heart, heart, club, club, club, club, club, spade, spade);                     \n    printf(\"\\n        %c%c        %c  %c       %c     %c   %c   %c              \", diamond, diamond, heart, heart, club, club, spade, spade);                                      \n    printf(\"\\n        %c%c       %c    %c     %c          %c  %c               \", diamond, diamond, heart, heart, club, spade, spade);                                           \n    printf(\"\\n        %c%c       %c %c%c %c     %c          %c %c              \", diamond, diamond, heart, heart, heart, heart, club, spade, spade);                                     \n    printf(\"\\n        %c%c      %c %c%c%c%c %c    %c          %c%c %c             \", diamond, diamond, heart, heart, heart, heart, heart, heart, club, spade, spade, spade);                                                \n    printf(\"\\n        %c%c      %c      %c    %c          %c   %c               \", diamond, diamond, heart, heart, club, spade, spade);                                                                               \n    printf(\"\\n     %c  %c%c     %c        %c    %c     %c   %c    %c             \", diamond, diamond, diamond, heart, heart, club, spade, spade);                                                                                                               \n    printf(\"\\n      %c%c%c      %c        %c     %c%c%c%c%c    %c     %c            \", diamond, diamond, diamond, heart, heart, club, club, club, club, club, spade, spade);                                                                                                                                        \n    printf(\"\\n\");  \n    printf(\"\\n         222                     111                         \");\n    printf(\"\\n        222                      111                         \");\n    printf(\"\\n       222                       111                         \");\n    printf(\"\\n      222222222222222      111111111111111                       \");\n    printf(\"\\n      2222222222222222    11111111111111111                         \");\n    printf(\"\\n\");\n    printf(\"\\n\");\n     \n    asktitle();\n     \n    printf(\"\\n\");\n    printf(\"\\n\");\n    return(0);\n} \/\/end program\n \nvoid asktitle() \/\/ Function for asking player if they want to continue\n{\n    char choice1;\n    int choice2;\n     \n     printf(\"\\n                 Are You Ready?\");\n     printf(\"\\n                ----------------\");\n     printf(\"\\n                      (Y\/N)\\n                        \");\n     scanf(\"\\n%c\",&amp;choice1);\n \n    while((choice1!='Y') &amp;&amp; (choice1!='y') &amp;&amp; (choice1!='N') &amp;&amp; (choice1!='n')) \/\/ If invalid choice entered\n    {                                                                           \n        printf(\"\\n\");\n        printf(\"Incorrect Choice. Please Enter Y for Yes or N for No.\\n\");\n        scanf(\"%c\",&amp;choice1);\n    }\n \n \n    if((choice1 == 'Y') || (choice1 == 'y')) \/\/ If yes, continue. Prints menu.\n    { \n\t    printf(\"\\033[2J\\033[1;1H\");\n            printf(\"\\nEnter 1 to Begin the Greatest Game Ever Played.\");\n            printf(\"\\nEnter 2 to See a Complete Listing of Rules.\");\n            printf(\"\\nEnter 3 to Exit Game. (Not Recommended)\");\n            printf(\"\\nChoice: \");\n            scanf(\"%d\", &amp;choice2); \/\/ Prompts user for choice\n            if((choice2&lt;1) || (choice2>3)) \/\/ If invalid choice entered\n            {\n                printf(\"\\nIncorrect Choice. Please enter 1, 2 or 3\\n\");\n                scanf(\"%d\", &amp;choice2);\n            }\n            switch(choice2) \/\/ Switch case for different choices\n            {   \n                case 1: \/\/ Case to begin game\n                   printf(\"\\033[2J\\033[1;1H\");                    \n                   play();                                       \n                   break;\n                    \n                case 2: \/\/ Case to see rules\n                   printf(\"\\033[2J\\033[1;1H\");\n                   rules();\n                   break;\n                    \n                case 3: \/\/ Case to exit game\n                   printf(\"\\nYour day could have been perfect.\");\n                   printf(\"\\nHave an almost perfect day!\\n\\n\");                   \n                   exit(0);\n                   break;\n                    \n                default:\n                   printf(\"\\nInvalid Input\");\n            } \/\/ End switch case\n    } \/\/ End if loop\n    \n             \n \n    else if((choice1 == 'N') || (choice1 == 'n')) \/\/ If no, exit program\n    {\n        printf(\"\\nYour day could have been perfect.\");\n        printf(\"\\nHave an almost perfect day!\\n\\n\");\n        printf(\"\\033[2J\\033[1;1H\");\n        exit(0);\n    }\n     \n    return;\n} \/\/ End function\n \nvoid rules() \/\/Prints \"Rules of Vlad's Blackjack\" list\n{\n     char choice1;\n     int choice2;\n      \n     printf(\"\\n           RULES of VLAD's BLACKJACK\");\n     printf(\"\\n          ---------------------------\");\n     printf(\"\\nI.\");\n     printf(\"\\n     Thou shalt not question the odds of this game.\");\n     printf(\"\\n      %c This program generates cards at random.\", spade);\n     printf(\"\\n      %c If you keep losing, you are very unlucky!\\n\", diamond);\n      \n     printf(\"\\nII.\");\n     printf(\"\\n     Each card has a value.\");\n     printf(\"\\n      %c Number cards 1 to 10 hold a value of their number.\", spade);\n     printf(\"\\n      %c J, Q, and K cards hold a value of 10.\", diamond);\n     printf(\"\\n      %c Ace cards hold a value of 11\", club);\n     printf(\"\\n     The goal of this game is to reach a card value total of 21.\\n\");\n      \n     printf(\"\\nIII.\");\n     printf(\"\\n     After the dealing of the first two cards, YOU must decide whether to HIT or STAY.\");\n     printf(\"\\n      %c Staying will keep you safe, hitting will add a card.\", spade);\n     printf(\"\\n     Because you are competing against the dealer, you must beat his hand.\");\n     printf(\"\\n     BUT BEWARE!.\");\n     printf(\"\\n      %c If your total goes over 21, you will LOSE!.\", diamond);\n     printf(\"\\n     But the world is not over, because you can always play again.\\n\");\n     printf(\"\\n%c%c%c YOUR RESULTS ARE RECORDED AND FOUND IN SAME FOLDER AS PROGRAM %c%c%c\\n\", spade, heart, club, club, heart, spade);\n     printf(\"\\nWould you like to go the previous screen? (I will not take NO for an answer)\");\n     printf(\"\\n                  (Y\/N)\\n                    \");\n\n     scanf(\"\\n%c\",&amp;choice1);\n      \n    while((choice1!='Y') &amp;&amp; (choice1!='y') &amp;&amp; (choice1!='N') &amp;&amp; (choice1!='n')) \/\/ If invalid choice entered\n    {                                                                           \n        printf(\"\\n\");\n        printf(\"Incorrect Choice. Please Enter Y for Yes or N for No.\\n\");\n        scanf(\"%c\",&amp;choice1);\n    }\n \n \n    if((choice1 == 'Y') || (choice1 == 'y')) \/\/ If yes, continue. Prints menu.\n    { \n            printf(\"\\033[2J\\033[1;1H\");\n            asktitle();\n    } \/\/ End if loop\n    \n             \n \n    else if((choice1 == 'N') || (choice1 == 'n')) \/\/ If no, convinces user to enter yes\n    {\n        printf(\"\\033[2J\\033[1;1H\");\n        printf(\"\\n                 I told you so.\\n\");\n        asktitle();\n    }\n     \n    return;\n} \/\/ End function\n \nint clubcard() \/\/Displays Club Card Image\n{  \n   \n    srand((unsigned) time(NULL)); \/\/Generates random seed for rand() function\n    k=rand()%13+1;\n     \n    if(k&lt;=9) \/\/If random number is 9 or less, print card with that number\n    {\n    \/\/Club Card\n    printf(\"-------\\n\");\n    printf(\"|%c    |\\n\", club);\n    printf(\"|  %d  |\\n\", k);\n    printf(\"|    %c|\\n\", club);\n    printf(\"-------\\n\");\n    }\n     \n     \n    if(k==10) \/\/If random number is 10, print card with J (Jack) on face\n    {\n    \/\/Club Card\n    printf(\"-------\\n\");\n    printf(\"|%c    |\\n\", club);\n    printf(\"|  J  |\\n\");\n    printf(\"|    %c|\\n\", club);\n    printf(\"-------\\n\");\n    }\n     \n     \n    if(k==11) \/\/If random number is 11, print card with A (Ace) on face\n    {\n    \/\/Club Card\n    printf(\"-------\\n\");\n    printf(\"|%c    |\\n\", club);\n    printf(\"|  A  |\\n\");\n    printf(\"|    %c|\\n\", club);\n    printf(\"-------\\n\");\n    if(player_total&lt;=10) \/\/If random number is Ace, change value to 11 or 1 depending on dealer total\n         {\n             k=11;\n         }\n          \n         else\n         {\n \n             k=1;\n         }\n    }\n     \n     \n    if(k==12) \/\/If random number is 12, print card with Q (Queen) on face\n    {\n    \/\/Club Card\n    printf(\"-------\\n\");\n    printf(\"|%c    |\\n\", club);\n    printf(\"|  Q  |\\n\");\n    printf(\"|    %c|\\n\", club);\n    printf(\"-------\\n\");\n    k=10; \/\/Set card value to 10\n    }\n     \n     \n    if(k==13) \/\/If random number is 13, print card with K (King) on face\n    {\n    \/\/Club Card\n    printf(\"-------\\n\");\n    printf(\"|%c    |\\n\", club);\n    printf(\"|  K  |\\n\");\n    printf(\"|    %c|\\n\", club);\n    printf(\"-------\\n\");\n    k=10; \/\/Set card value to 10\n    }\n    return k;           \n}\/\/ End function\n \nint diamondcard() \/\/Displays Diamond Card Image\n{\n     \n    srand((unsigned) time(NULL)); \/\/Generates random seed for rand() function\n    k=rand()%13+1;\n     \n    if(k&lt;=9) \/\/If random number is 9 or less, print card with that number\n    {\n    \/\/Diamond Card\n    printf(\"-------\\n\");\n    printf(\"|%c    |\\n\", diamond);\n    printf(\"|  %d  |\\n\", k);\n    printf(\"|    %c|\\n\", diamond);\n    printf(\"-------\\n\");\n    }\n     \n    if(k==10) \/\/If random number is 10, print card with J (Jack) on face\n    {\n    \/\/Diamond Card\n    printf(\"-------\\n\");\n    printf(\"|%c    |\\n\", diamond);\n    printf(\"|  J  |\\n\");\n    printf(\"|    %c|\\n\", diamond);\n    printf(\"-------\\n\");\n    }\n     \n    if(k==11) \/\/If random number is 11, print card with A (Ace) on face\n    {\n    \/\/Diamond Card\n    printf(\"-------\\n\");\n    printf(\"|%c    |\\n\", diamond);\n    printf(\"|  A  |\\n\");\n    printf(\"|    %c|\\n\", diamond);\n    printf(\"-------\\n\");\n    if(player_total&lt;=10) \/\/If random number is Ace, change value to 11 or 1 depending on dealer total\n         {\n             k=11;\n         }\n          \n         else\n         {\n             k=1;\n         }\n    }\n     \n    if(k==12) \/\/If random number is 12, print card with Q (Queen) on face\n    {\n    \/\/Diamond Card\n    printf(\"-------\\n\");\n    printf(\"|%c    |\\n\", diamond);\n    printf(\"|  Q  |\\n\");\n    printf(\"|    %c|\\n\", diamond);\n    printf(\"-------\\n\");\n    k=10; \/\/Set card value to 10\n    }\n     \n    if(k==13) \/\/If random number is 13, print card with K (King) on face\n    {\n    \/\/Diamond Card\n    printf(\"-------\\n\");\n    printf(\"|%c    |\\n\", diamond);\n    printf(\"|  K  |\\n\");\n    printf(\"|    %c|\\n\", diamond);\n    printf(\"-------\\n\");\n    k=10; \/\/Set card value to 10\n    }\n    return k;\n}\/\/ End function\n \nint heartcard() \/\/Displays Heart Card Image\n{\n     \n    srand((unsigned) time(NULL)); \/\/Generates random seed for rand() function\n    k=rand()%13+1;\n     \n    if(k&lt;=9) \/\/If random number is 9 or less, print card with that number\n    {\n    \/\/Heart Card\n    printf(\"-------\\n\");\n    printf(\"|%c    |\\n\", heart); \n    printf(\"|  %d  |\\n\", k);\n    printf(\"|    %c|\\n\", heart);\n    printf(\"-------\\n\");\n    }\n     \n    if(k==10) \/\/If random number is 10, print card with J (Jack) on face\n    {\n    \/\/Heart Card\n    printf(\"-------\\n\");\n    printf(\"|%c    |\\n\", heart);\n    printf(\"|  J  |\\n\");\n    printf(\"|    %c|\\n\", heart);\n    printf(\"-------\\n\");\n    }\n     \n    if(k==11) \/\/If random number is 11, print card with A (Ace) on face\n    {\n    \/\/Heart Card\n    printf(\"-------\\n\");\n    printf(\"|%c    |\\n\", heart);\n    printf(\"|  A  |\\n\");\n    printf(\"|    %c|\\n\", heart);\n    printf(\"-------\\n\");\n    if(player_total&lt;=10) \/\/If random number is Ace, change value to 11 or 1 depending on dealer total\n         {\n             k=11;\n         }\n          \n         else\n         {\n             k=1;\n         }\n    }\n     \n    if(k==12) \/\/If random number is 12, print card with Q (Queen) on face\n    {\n    \/\/Heart Card\n    printf(\"-------\\n\");\n    printf(\"|%c    |\\n\", heart);\n    printf(\"|  Q  |\\n\");\n    printf(\"|    %c|\\n\", heart);\n    printf(\"-------\\n\");\n    k=10; \/\/Set card value to 10\n    }\n     \n    if(k==13) \/\/If random number is 13, print card with K (King) on face\n    {\n    \/\/Heart Card\n    printf(\"-------\\n\");\n    printf(\"|%c    |\\n\", heart);\n    printf(\"|  K  |\\n\");\n    printf(\"|    %c|\\n\", heart);\n    printf(\"-------\\n\");\n    k=10; \/\/Set card value to 10\n    }\n    return k;\n} \/\/ End Function\n \nint spadecard() \/\/Displays Spade Card Image\n{\n     \n    srand((unsigned) time(NULL)); \/\/Generates random seed for rand() function\n    k=rand()%13+1;\n     \n    if(k&lt;=9) \/\/If random number is 9 or less, print card with that number\n    {\n    \/\/Spade Card\n    printf(\"-------\\n\");\n    printf(\"|%c    |\\n\", spade);\n    printf(\"|  %d  |\\n\", k);\n    printf(\"|    %c|\\n\", spade);\n    printf(\"-------\\n\");\n    }\n     \n    if(k==10) \/\/If random number is 10, print card with J (Jack) on face\n    {\n    \/\/Spade Card\n    printf(\"-------\\n\");\n    printf(\"|%c    |\\n\", spade);\n    printf(\"|  J  |\\n\");\n    printf(\"|    %c|\\n\", spade);\n    printf(\"-------\\n\");\n    }\n     \n    if(k==11) \/\/If random number is 11, print card with A (Ace) on face\n    {\n    \/\/Spade Card\n    printf(\"-------\\n\");\n    printf(\"|%c    |\\n\", spade);\n    printf(\"|  A  |\\n\");\n    printf(\"|    %c|\\n\", spade);\n    printf(\"-------\\n\");\n    if(player_total&lt;=10) \/\/If random number is Ace, change value to 11 or 1 depending on dealer total\n         {\n             k=11;\n         }\n          \n         else\n         {\n             k=1;\n         }\n    }\n     \n    if(k==12) \/\/If random number is 12, print card with Q (Queen) on face\n    {\n    \/\/Spade Card\n    printf(\"-------\\n\");\n    printf(\"|%c    |\\n\", spade);\n    printf(\"|  Q  |\\n\");\n    printf(\"|    %c|\\n\", spade);\n    printf(\"-------\\n\");\n    k=10; \/\/Set card value to 10\n    }\n     \n    if(k==13) \/\/If random number is 13, print card with K (King) on face\n    {\n    \/\/Spade Card\n    printf(\"-------\\n\");\n    printf(\"|%c    |\\n\", spade);\n    printf(\"|  K  |\\n\");\n    printf(\"|    %c|\\n\", spade);\n    printf(\"-------\\n\");\n    k=10; \/\/Set card value to 10\n    }\n    return k;\n} \/\/ End Function\n \nint randcard() \/\/Generates random card\n{\n                \n     srand((unsigned) time(NULL)); \/\/Generates random seed for rand() function\n     random_card = rand()%4+1;\n      \n     if(random_card==1)\n     {   \n         clubcard();\n         l=k;\n     }\n      \n     if(random_card==2)\n     {\n         diamondcard();\n         l=k;\n     }\n      \n     if(random_card==3)\n     {\n         heartcard();\n         l=k;\n     }\n          \n     if(random_card==4)\n     {\n         spadecard();\n         l=k;\n     }    \n     return l;\n} \/\/ End Function   \n\n \nvoid play() \/\/Plays game\n{\n      \n     int p=0; \/\/ holds value of player_total\n     int i=1; \/\/ counter for asking user to hold or stay (aka game turns)\n     char choice3;\n      \n     cash = cash;\n     cash_test();\n     printf(\"\\nCash: $%d\\n\",cash); \/\/Prints amount of cash user has\n     randcard(); \/\/Generates random card\n     player_total = p + l; \/\/Computes player total\n     p = player_total;\n     printf(\"\\nYour Total is %d\\n\", p); \/\/Prints player total\n     dealer(); \/\/Computes and prints dealer total\n     betting(); \/\/Prompts user to enter bet amount\n        \n     while(i&lt;=21) \/\/While loop used to keep asking user to hit or stay at most twenty-one times\n                  \/\/  because there is a chance user can generate twenty-one consecutive 1's\n     {\n         if(p==21) \/\/If user total is 21, win\n         {\n             printf(\"\\nUnbelievable! You Win!\\n\");\n             won = won+1;\n             cash = cash+bet;\n             printf(\"\\nYou have %d Wins and %d Losses. Awesome!\\n\", won, loss);\n             dealer_total=0;\n             askover();\n         }\n      \n         if(p>21) \/\/If player total is over 21, loss\n         {\n             printf(\"\\nWoah Buddy, You Went WAY over.\\n\");\n             loss = loss+1;\n             cash = cash - bet;\n             printf(\"\\nYou have %d Wins and %d Losses. Awesome!\\n\", won, loss);\n             dealer_total=0;\n             askover();\n         }\n      \n         if(p&lt;=21) \/\/If player total is less than 21, ask to hit or stay\n         {         \n             printf(\"\\n\\nWould You Like to Hit or Stay?\");\n              \n             scanf(\"%c\", &amp;choice3);\n             while((choice3!='H') &amp;&amp; (choice3!='h') &amp;&amp; (choice3!='S') &amp;&amp; (choice3!='s')) \/\/ If invalid choice entered\n             {                                                                           \n                 printf(\"\\n\");\n                 printf(\"Please Enter H to Hit or S to Stay.\\n\");\n                 scanf(\"%c\",&amp;choice3);\n             }\n \n             if((choice3=='H') || (choice3=='h')) \/\/ If Hit, continues\n             { \n                 randcard();\n                 player_total = p + l;\n                 p = player_total;\n                 printf(\"\\nYour Total is %d\\n\", p);\n                 dealer();\n                  if(dealer_total==21) \/\/Is dealer total is 21, loss\n                  {\n                      printf(\"\\nDealer Has the Better Hand. You Lose.\\n\");\n                      loss = loss+1;\n                      cash = cash - bet;\n                      printf(\"\\nYou have %d Wins and %d Losses. Awesome!\\n\", won, loss);\n                      dealer_total=0;\n                      askover();\n                  } \n      \n                  if(dealer_total>21) \/\/If dealer total is over 21, win\n                  {                      \n                      printf(\"\\nDealer Has Went Over!. You Win!\\n\");\n                      won = won+1;\n                      cash = cash+bet;\n                      printf(\"\\nYou have %d Wins and %d Losses. Awesome!\\n\", won, loss);\n                      dealer_total=0;\n                      askover();\n                  }\n             }\n             if((choice3=='S') || (choice3=='s')) \/\/ If Stay, does not continue\n             {\n                printf(\"\\nYou Have Chosen to Stay at %d. Wise Decision!\\n\", player_total);\n                stay();\n             }\n          }\n             i++; \/\/While player total and dealer total are less than 21, re-do while loop \n     } \/\/ End While Loop\n} \/\/ End Function\n \nvoid dealer() \/\/Function to play for dealer AI\n{\n     int z;\n      \n     if(dealer_total&lt;17)\n     {\n      srand((unsigned) time(NULL) + 1); \/\/Generates random seed for rand() function\n      z=rand()%13+1;\n      if(z&lt;=10) \/\/If random number generated is 10 or less, keep that value\n      {\n         d=z;\n          \n      }\n      \n      if(z>11) \/\/If random number generated is more than 11, change value to 10\n      {\n         d=10;\n      }\n      \n      if(z==11) \/\/If random number is 11(Ace), change value to 11 or 1 depending on dealer total\n      {\n         if(dealer_total&lt;=10)\n         {\n             d=11;\n         }\n          \n         else\n         {\n             d=1;\n         }\n      }\n     dealer_total = dealer_total + d;\n     }\n           \n     printf(\"\\nThe Dealer Has a Total of %d\", dealer_total); \/\/Prints dealer total\n      \n} \/\/ End Function \n \nvoid stay() \/\/Function for when user selects 'Stay'\n{\n     dealer(); \/\/If stay selected, dealer continues going\n     if(dealer_total>=17)\n     {\n      if(player_total>=dealer_total) \/\/If player's total is more than dealer's total, win\n      {\n         printf(\"\\nUnbelievable! You Win!\\n\");\n         won = won+1;\n         cash = cash+bet;\n         printf(\"\\nYou have %d Wins and %d Losses. Awesome!\\n\", won, loss);\n         dealer_total=0;\n         askover();\n      }\n      if(player_total&lt;dealer_total) \/\/If player's total is less than dealer's total, loss\n      {\n         printf(\"\\nDealer Has the Better Hand. You Lose.\\n\");\n         loss = loss+1;\n         cash = cash - bet;\n         printf(\"\\nYou have %d Wins and %d Losses. Awesome!\\n\", won, loss);\n         dealer_total=0;\n         askover();\n      }\n      if(dealer_total>21) \/\/If dealer's total is more than 21, win\n      {\n         printf(\"\\nUnbelievable! You Win!\\n\");\n         won = won+1;\n         cash = cash+bet;\n         printf(\"\\nYou have %d Wins and %d Losses. Awesome!\\n\", won, loss);\n         dealer_total=0;\n         askover();\n      }\n     }\n     else\n     {\n         stay();\n     }\n      \n} \/\/ End Function\n \nvoid cash_test() \/\/Test for if user has cash remaining in purse\n{\n     if (cash &lt;= 0) \/\/Once user has zero remaining cash, game ends and prompts user to play again\n     {\n        printf(\"You Are Bankrupt. Game Over\");\n        cash = 500;\n        askover();\n     }\n     if (cash > 1000000){\n     \tFILE* fp=fopen(\"flag\", \"r\");\n\tchar buf[100];\n\tmemset(buf, 0, 100);\n\tfread(buf, 1, 100, fp);\n\tprintf(\"%s\\n\", buf);\n\tfclose(fp);\n     }\n} \/\/ End Function\n \nint betting() \/\/Asks user amount to bet\n{\n printf(\"\\n\\nEnter Bet: $\");\n scanf(\"%d\", &amp;bet);\n \n if (bet > cash) \/\/If player tries to bet more money than player has\n {\n        printf(\"\\nYou cannot bet more money than you have.\");\n        printf(\"\\nEnter Bet: \");\n        scanf(\"%d\", &amp;bet);\n        return bet;\n }\n else return bet;\n} \/\/ End Function\n \nvoid askover() \/\/ Function for asking player if they want to play again\n{\n    char choice1;\n         \n     printf(\"\\nWould You Like To Play Again?\");\n     printf(\"\\nPlease Enter Y for Yes or N for No\\n\");\n     scanf(\"\\n%c\",&amp;choice1);\n \n    while((choice1!='Y') &amp;&amp; (choice1!='y') &amp;&amp; (choice1!='N') &amp;&amp; (choice1!='n')) \/\/ If invalid choice entered\n    {                                                                           \n        printf(\"\\n\");\n        printf(\"Incorrect Choice. Please Enter Y for Yes or N for No.\\n\");\n        scanf(\"%c\",&amp;choice1);\n    }\n \n \n    if((choice1 == 'Y') || (choice1 == 'y')) \/\/ If yes, continue.\n    { \n            printf(\"\\033[2J\\033[1;1H\");\n            play();\n    }\n  \n    else if((choice1 == 'N') || (choice1 == 'n')) \/\/ If no, exit program\n    {\n        fileresults();\n        printf(\"\\nBYE!!!!\\n\\n\");\n        printf(\"\\033[2J\\033[1;1H\");\n        exit(0);\n    }\n    return;\n} \/\/ End function\n \nvoid fileresults() \/\/Prints results into Blackjack.txt file in program directory\n{\n     return;\n} \/\/ End Function<\/pre>\n\n\n\n<h1 class=\"wp-block-heading\">Analysis<\/h1>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"c\" data-enlighter-theme=\"dracula\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">void cash_test() \/\/Test for if user has cash remaining in purse\n{\n     if (cash &lt;= 0) \/\/Once user has zero remaining cash, game ends and prompts user to play again\n     {\n        printf(\"You Are Bankrupt. Game Over\");\n        cash = 500;\n        askover();\n     }\n     if (cash > 1000000){\n     \tFILE* fp=fopen(\"flag\", \"r\");\n\tchar buf[100];\n\tmemset(buf, 0, 100);\n\tfread(buf, 1, 100, fp);\n\tprintf(\"%s\\n\", buf);\n\tfclose(fp);\n     }\n} \/\/ End Function\n<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><code>cash_test<\/code> \ud568\uc218\uc5d0\uc11c <code>cash<\/code> \uac12\uc774 1000000\ubcf4\ub2e4 \ud06c\uba74 flag\ub97c \ud68d\ub4dd\ud560 \uc218 \uc788\ub2e4.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\ubca0\ud305 \uae08\uc561\uc744 <strong>2148483648<\/strong>\uc73c\ub85c \uc124\uc815\ud574\uc8fc\uba74, <code>cash<\/code> \ubcc0\uc218\uac00 <code>signed int<\/code> \ud0c0\uc785\uc774\ubbc0\ub85c, -2146483648 \uac12\uc774 \ub41c\ub2e4.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\ub530\ub77c\uc11c <code>bet &gt; cash<\/code> \u2192 <code>-2146483648 &gt; 500<\/code>\uc77c \ub54c false\uc774\ubbc0\ub85c \uac80\uc0ac\ub97c \ud1b5\uacfc\ud560 \uc218 \uc788\ub2e4.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"c\" data-enlighter-theme=\"dracula\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">int betting() \/\/Asks user amount to bet\n{\n printf(\"\\n\\nEnter Bet: $\");\n scanf(\"%d\", &amp;bet);\n \n if (bet > cash) \/\/If player tries to bet more money than player has\n {\n        printf(\"\\nYou cannot bet more money than you have.\");\n        printf(\"\\nEnter Bet: \");\n        scanf(\"%d\", &amp;bet);\n        return bet;\n }\n else return bet;\n} \/\/ End Function<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\uc9c8 \uacbd\uc6b0:<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\uae30\uc874 cash \uac12\uc774 500\uc774\uace0, -2146483648\uc744 \ube7c\uba74 +\uac00 \ub418\ubbc0\ub85c<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"raw\" data-enlighter-theme=\"dracula\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">>>> 2146483648 + 500\n2146484148<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">2146484148\uac00 \ub41c\ub2e4. \ub530\ub77c\uc11c flag\uac00 \ud68d\ub4dd \uac00\ub2a5\ud558\ub2e4.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"raw\" data-enlighter-theme=\"dracula\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">Cash: $500\n-------\n|D    |\n|  6  |\n|    D|\n-------\n\nYour Total is 6\n\nThe Dealer Has a Total of 9\n\nEnter Bet: $2148483648\n\n\nWould You Like to Hit or Stay?\nPlease Enter H to Hit or S to Stay.\nS\n\nYou Have Chosen to Stay at 6. Wise Decision!\n\nThe Dealer Has a Total of 11\nThe Dealer Has a Total of 13\nThe Dealer Has a Total of 15\nThe Dealer Has a Total of 17\nDealer Has the Better Hand. You Lose.\n\nYou have 0 Wins and 1 Losses. Awesome!\n\nWould You Like To Play Again?\nPlease Enter Y for Yes or N for No\nY\n\nWoohoo_I_am_now_a_MILL10NAIRE!\n\n\nCash: $2146484148\n-------\n|S    |\n|  3  |\n|    S|\n-------\n\nYour Total is 3\n\nThe Dealer Has a Total of 6\n\nEnter Bet: $<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\uc774\uae38 \uacbd\uc6b0:<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\uae30\uc874 cash \uac12\uc774 500\uc774\uace0, -2146483648\uc744 \ub354\ud558\uba74 \uacb0\uad6d \ube7c\ub294\uac70\ub77c\uc11c<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"raw\" data-enlighter-theme=\"dracula\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">>>> 500 - 2146483648\n-2146483148<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">-2146483148\uac00 \ub418\ubbc0\ub85c \ud30c\uc0b0.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"raw\" data-enlighter-theme=\"dracula\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">Cash: $500\n-------\n|C    |\n|  6  |\n|    C|\n-------\n\nYour Total is 6\n\nThe Dealer Has a Total of 10\n\nEnter Bet: $2148483648\n\n\nWould You Like to Hit or Stay?\nPlease Enter H to Hit or S to Stay.\nH\n-------\n|H    |\n|  7  |\n|    H|\n-------\n\nYour Total is 13\n\nThe Dealer Has a Total of 20\n\nWould You Like to Hit or Stay?\nPlease Enter H to Hit or S to Stay.\nH\n-------\n|H    |\n|  7  |\n|    H|\n-------\n\nYour Total is 20\n\nThe Dealer Has a Total of 20\n\nWould You Like to Hit or Stay?\nPlease Enter H to Hit or S to Stay.\nS\n\nYou Have Chosen to Stay at 20. Wise Decision!\n\nThe Dealer Has a Total of 20\nUnbelievable! You Win!\n\nYou have 1 Wins and 0 Losses. Awesome!\n\nWould You Like To Play Again?\nPlease Enter Y for Yes or N for No\nY\n\nYou Are Bankrupt. Game Over\nWould You Like To Play Again?\nPlease Enter Y for Yes or N for No<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Description Source Code Analysis cash_test \ud568\uc218\uc5d0\uc11c cash \uac12\uc774 1000000\ubcf4\ub2e4 \ud06c\uba74 flag\ub97c \ud68d\ub4dd\ud560 \uc218 \uc788\ub2e4. \ubca0\ud305 \uae08\uc561\uc744 2148483648\uc73c\ub85c \uc124\uc815\ud574\uc8fc\uba74, cash \ubcc0\uc218\uac00 signed int \ud0c0\uc785\uc774\ubbc0\ub85c, -2146483648 \uac12\uc774 \ub41c\ub2e4. \ub530\ub77c\uc11c bet &gt; cash \u2192 -2146483648 &gt; 500\uc77c \ub54c false\uc774\ubbc0\ub85c \uac80\uc0ac\ub97c \ud1b5\uacfc\ud560 \uc218 \uc788\ub2e4. \uc9c8 \uacbd\uc6b0: \uae30\uc874 cash \uac12\uc774 500\uc774\uace0, -2146483648\uc744 \ube7c\uba74 +\uac00 \ub418\ubbc0\ub85c 2146484148\uac00 \ub41c\ub2e4. \ub530\ub77c\uc11c flag\uac00 \ud68d\ub4dd&hellip;&nbsp;<a href=\"https:\/\/h4ck.kr\/?p=3261\" rel=\"bookmark\">\ub354 \ubcf4\uae30 &raquo;<span class=\"screen-reader-text\">blackjack<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"neve_meta_sidebar":"","neve_meta_container":"","neve_meta_enable_content_width":"","neve_meta_content_width":0,"neve_meta_title_alignment":"","neve_meta_author_avatar":"","neve_post_elements_order":"","neve_meta_disable_header":"","neve_meta_disable_footer":"","neve_meta_disable_title":"","footnotes":""},"categories":[4],"tags":[25],"class_list":["post-3261","post","type-post","status-publish","format-standard","hentry","category-pwnable-kr","tag-pwnable"],"_links":{"self":[{"href":"https:\/\/h4ck.kr\/index.php?rest_route=\/wp\/v2\/posts\/3261","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/h4ck.kr\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/h4ck.kr\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/h4ck.kr\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/h4ck.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3261"}],"version-history":[{"count":1,"href":"https:\/\/h4ck.kr\/index.php?rest_route=\/wp\/v2\/posts\/3261\/revisions"}],"predecessor-version":[{"id":3262,"href":"https:\/\/h4ck.kr\/index.php?rest_route=\/wp\/v2\/posts\/3261\/revisions\/3262"}],"wp:attachment":[{"href":"https:\/\/h4ck.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3261"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/h4ck.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3261"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/h4ck.kr\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3261"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}