Like Tree1Likes
  • 1 Post By CommonTater

C program Blackjack

This is a discussion on C program Blackjack within the Game Programming forums, part of the General Programming Boards category; Here is alittle something I wrote for my final project for my c programming class. I wanted to see what ...

  1. #1
    Registered User
    Join Date
    Apr 2011
    Posts
    4

    C program Blackjack

    Here is alittle something I wrote for my final project for my c programming class. I wanted to see what people thought of it and feel free to use it for school. I cited a blackjack program online which can be found below to help me get started. I made a several changes so its resemblance is closer to real blackjack. Although i didn't add in side bets, double down, or any other special betting functions because time issues. Although I did:

    1. Improved card graphics and rule list boarder.
    2. Added a function so you cannot see dealers first card until dealers turn.
    3. Fixed the seed for rand() which was creating same card repeatedly.
    4. Moved the description out from the code to cut down on clutter.
    5. Fixed several bugs in many of the loops.

    If you have anything to add let me know I'm fairly new to programming. I'm sure there are ways to shorten my code up and other things I've missed and if nothing else perhaps it may answer questions or even help you if you find yourself in the same boat I am.

    Thanks

    Descriptions of each part are numbered by DXX (i.e. DOO) the corresponding code begins with /*Lxx*/ (i.e. /*L00*/)

    Code:
    //							BlackjackFMJ
    //							BlackjackFMJ.c
    //F.  Marvin
    
    //Work Cited
    //-----------
    //Vladislav Shulman, Blackjack
    //http://cboard.cprogramming.com/c-programming/114023-simple-blackjack-program.html
    
    //
    
    //----------
    //C includes
    //----------
    #include <stdlib.h>
    #include <stdio.h>
    #include <math.h>
    #include <time.h> 
    #include <process.h>
    
    #define spade 06                 
    #define club 05                  
    #define diamond 04               
    #define heart 03                 
    #define RESULTS "Blackjack.txt"  
    
    //----------------
    //Global Variables
    //----------------
    int	dealerCardOne,
    	dealersHand,
    	dealerHiddenCard,
    	dealerTotal,
    	gameBet,
    	gameCash = 500,
    	gameLoss,
    	gameWon,
    	nextCard,
    	nextSuite,
    	playerTotal = 0,
    	randomCard;
    
    //-------------------
    //Function Prototypes
    //-------------------
    void	askOver(),
    	askTitle(),
    	cashTest(),
    	dealerBot(),
    	dealerFirstCard(),
    	fileResults(),
    	gameRules(),        
    	gamePlay(), 
    	gameStay();  
    
    int	clubCard(),      
    	diamondCard(),
    	gameBetting(),
    	heartCard(),          
    	randCard(),     
    	spadeCard();             
    
    /*************************************
    DESCRIPTION- main
    D00 Generate random seed for rand();
    D01 Call askTitle to bring up startup screen;
    D02 System pause;
           Return;
    **************************************/
    int main(void)
    {  
    /*L00*/	srand((unsigned) time(NULL));
    /*L01*/	askTitle();
    /*L02*/	system("pause");
    	return(0);
    }//main
    
    /*************************************
    DESCRIPTION- askOver
    D00 char choiceOne;
    
    D01 Display ask to play again;
    D02 Obtain choiceOne;
    D03 While((choiceOne!='Y') && (choiceOne!='y') && (choiceOne!='N') && (choiceOne!='n'))
           {
    	Dispay incorrect choice;
    	Obtain choiceOne;
           }//while
    D04 If (choiceOne == yes)
           {
    	System clear;
    	Call gamePlay;
           }//If
    D05 Else If (choiceOne == no)
           {
    	Call fileResults;
    	Dispay closing;
    	System pause;
    	exit;
            }//Else if
            Return;
    **************************************/
    void
    askOver() 
    {
    /*L00*/	char choiceOne;
            
    /*L01*/	printf("Would you like to play again (please enter Y for Yes or N for No)?");
    /*L02*/	scanf_s("\n%c", &choiceOne);
    
    /*L03*/	while((choiceOne!='Y') && (choiceOne!='y') && (choiceOne!='N') && (choiceOne!='n')) 
    	{                                                                           
    		printf("\n\nIncorrect choice. Please enter Y for Yes or N for No:");
    		scanf_s("%c",&choiceOne);
    	}//while
    	
    /*L04*/	if((choiceOne == 'Y') || (choiceOne == 'y')) 
    	{ 
    		system("cls");
    		gamePlay();
    	}//if
     
    /*L05*/	else if((choiceOne == 'N') || (choiceOne == 'n')) 
    	{
    		fileResults();
    		printf("\n\nExiting Marvin's Blackjack\n");
    		printf("---------------------------\n");
    		system("pause");
    		exit(0);
    	}//else if
    	return;
    }//askOver
    
    /*************************************
    DESCRIPTION- askTitle
    D00 char choiceOne;
           int choiceTwo;
    
    D01 Display opening;
    D02 Obtain choiceOne;
    D03 While((choiceOne!='Y') && (choiceOne!='y') && (choiceOne!='N') && (choiceOne!='n'))
           {
    	Dispay incorrect choice;
    	Obtain choiceOne;
           }//while
    D04 If (choiceOne == yes)
           {
    	System clear;
    	Display game choices;
    	Obtain choiceTwo;
    
    D05	If((choiceTwo<1) || (choiceTwo>3)
    	{
    		Dispay incorrect choice;
    		Obtain choiceTwo;
    	}//If
    D06	Switch (Choicetwo)
    	{
    		Case 1:
    			System clear;
    			Call gamePlay;
    			Break;
    		Case 2:
    			System clear;
    			Call GameRules;
    			Break;
    		Case 3:
    			Display exiting game;
    			System pause;
    			System exit;
    			Break;
    		Default:
    			Display Invalid input;
    		}//Switch
    	}//If
    D07	Else If((choiceOne == 'N') || (choiceOne == 'n'))
    	{
    		Display exiting game;
    		System pause;
    		System exit;
    	}//Else If
    	Return;
    **************************************/
    void 
    askTitle() 
    {
    /*L00*/	char choiceOne;
    	int choiceTwo;
        
    /*L01*/	printf("Entering Marvin's Blackjack\n");
    	printf("---------------------------\n");
    	printf("|%c     Are you ready?    %c|\n", spade, spade);
    	printf("---------------------------\n");
    	printf("         (Y/N)\n     ");
    /*L02*/	scanf_s("\n    %c",&choiceOne);
    
    /*L03*/	while((choiceOne!='Y') && (choiceOne!='y') && (choiceOne!='N') && (choiceOne!='n')) 
    	{                                                                           
    		printf("\n");
    	                printf("Incorrect choice. Please enter Y for Yes or N for No.\n");
    		scanf_s("%c",&choiceOne);
    	}
    
    /*L04*/	if((choiceOne == 'Y') || (choiceOne == 'y')) 
    	{ 
    		system("cls");
    		printf("Enter 1 to begin the greatest game ever played.\n");
    		printf("Enter 2 to see a complete listing of rules.\n");
    		printf("Enter 3 to Exit Game.\n" );                      
    		printf("Choice: ");
    		scanf_s("\n%d", &choiceTwo); 
    	
    /*L05*/	               if((choiceTwo<1) || (choiceTwo>3)) 
    		{
    			printf("Incorrect choice. Please enter 1, 2 or 3");
    			scanf_s("\n%d", &choiceTwo);
    		}
    /*L06*/		switch(choiceTwo) 
    		{   
    			case 1: 
    				system("cls");
    				gamePlay();
    				break;
                       
    			case 2: 
    				system("cls");
    				gameRules();
    				break;
                       
    			case 3: 
    				printf("Your day could have been perfect.\n");
    				printf("Have an almost perfect day!\n\n");
    				printf("Exiting Marvin's Blackjack\n");
    				printf("---------------------------\n");
    				system("pause");
    				exit(0);
    				break;
                       
    			default:
    			               printf("Invalid Input\n");
    			}//switch 
    		}//if
    
    /*L07*/	else if((choiceOne == 'N') || (choiceOne == 'n')) 
    	{
    		printf("Your day could have been perfect.\n");
    		printf("Have an almost perfect day!\n\n");
    		printf("Exiting Marvin's Blackjack\n");
    		printf("---------------------------\n");
    		system("pause");
    		exit(0);
    	}//else if
    	return;
    }//askTitle
    
    /*************************************
    DESCRIPTION- cashTest
    D00          If (gameCash is less than or equal to zero)
    	{
    		Display bankrupt and game over;
    		Set gameCash = 500;
    		Call askOver;
    	}//If
    **************************************/
    void 
    cashTest() 
    {
    /*L00*/	if (gameCash <= 0)
    	{
    		printf("You are bankrupt. Game Over\n");
    		gameCash = 500;
    		askOver();
    	}//if
    }//cashTest
    
    /*************************************
    DESCRIPTION- dealerBot
    D00	int moreCards;
    D01      If (dealerTotal is less than 17)
    	{
    		Set moreCards = rand()%13 + 1;
    D02	          If(moreCards is less than or equals 10)
    		{
    			Set dealersHand to moreCards;
    		}//If
    D03	          If(moreCards is greater than 11)
    		{
    			Set dealersHand to 10;
    		}//If
    D04	          If(moreCards equals 11)
    		{
    D05		If(moreCards less than or equal to 11)
    		{
    			Set dealerHand to 11;
    		}//If
    D06		Else
    		{
    			Set dealersHand to 1;
    		}//Else
    	}//If
    D07	Set dealerTotal to dealerTotal plus dealersHand;
            }//If
    D08 Display dealers visable hand;
    **************************************/
    void 
    dealerBot()
    {
    /*L00*/	int moreCards;
         
    /*L01*/  if(dealerTotal < 17)
    	{
    		moreCards = rand()%13 + 1;
    /*L02*/	        if(moreCards <= 10) 
    		{
    			dealersHand = moreCards; 
    		}//if
         
    /*L03*/	        if(moreCards > 11)
    		{
    			dealersHand = 10;
    		}//if
         
    /*L04*/	         if(moreCards == 11)
    		{
    /*L05*/		        if(dealerTotal <= 10)
    			{
    				dealersHand = 11;
    			}//if
             
    /*L06*/			else
    			{
    				dealersHand = 1;
    			}//else
    		}//if
    /*L07*/		dealerTotal = dealerTotal + dealersHand;
    	}//if
    /*L08*/	printf("The dealer's visible hand has a total of %d.\n\n", dealerTotal -  dealerHiddenCard);
    }//dealerBot
    
    /*************************************
    DESCRIPTION- dealersFirstCard
    D00 int cardHolder;
    
    D01	Set cardHolder equal to rand()%13+1;
    D02	If(cardHolder is less than or equal to 10)
    	{
    		Set DealerHiddenCard to cardHolder;
    	}//if
    D03	If(cardHolder greater than 11)
    	{
    		Set dealerHiddenCard to 10;
    	}//If
    D04	If(cardHolder is equal to 11)
    	{
    D05		If(dealerCardOne is less than or equal to 10)
    		{
    			Set dealerHiddenCard to 11;
    		}//If
             
    D06		Else
    		{
    			Set dealerHiddenCard to 1;
    		}//Else
    	}//if
    D07	Set dealerTotal to dealerCardOne plus dealerHiddenCard;
    **************************************/
    void
    dealerFirstCard()
    {
    /*L00*/	int cardHolder;
         
    /*L01*/	cardHolder = rand()%13+1;
    /*L02*/	if(cardHolder <= 10) 
    	{
    		dealerHiddenCard = cardHolder;
    	}//if
         
    /*L03*/	if(cardHolder > 11)
    	{
    		dealerHiddenCard = 10;
    	}//if
         
    /*L04*/	if(cardHolder == 11)
    	{
    /*L05*/		if(dealerCardOne <= 10)
    		{
    			dealerHiddenCard = 11;
    		}//if
             
    /*L06*/		 else
    		{
    			dealerHiddenCard = 1;
    		}//else
    	}//if
    /*L07*/	dealerTotal = dealerCardOne + dealerHiddenCard;
    }//dealersFirstCard
    
    /*************************************
    DESCRIPTION- fileResults
    D00  FILE *fpresults;
    D01  fpresults = fopen(RESULTS, "w");
    D02  If(fpresults is equal to NULL)
           {
    	Display file missing;
                    System pause;
                    Exit(1);
           }//If
        
    D03     Else
               {     
    		Dispay results;
    		Display number of times won;
    		Display number of times lost;
              }//Else
    D04 fclose(fpresults);
           Return;
    **************************************/
    void 
    fileResults()
    {
    /*L00*/	FILE *fpresults;
    /*L01*/	fpresults = fopen(RESULTS, "w");
    /*L02*/	if(fpresults == NULL)
    	{
    		printf("\nError: File Missing\n");
    		system("pause");
    		exit(1);
    	}//if
        
    /*L03*/	else
    	{     
    		fprintf(fpresults,"\n\t RESULTS");
    		fprintf(fpresults,"\n\t---------\n");
    		fprintf(fpresults,"\nYou Have Won %d Times\n", gameWon);
    		fprintf(fpresults,"\nYou Have Lost %d Times\n", gameLoss);
    	}//else
    /*L04*/    fclose(fpresults);
    	return;
    }//cashTest
    
    /*************************************
    DESCRIPTION- gameRules
    D00 char choiceOne;
    
    D01 Display game rules;
    D02 Obtain choiceOne;
    
    D03 While((choiceOne != 'Y') && (choiceOne != 'y') && (choiceOne != 'N') && (choiceOne != 'n'))
          {
    	Dispay incorrect choice;
    	Obtain choiceOne;
           }//while
    D04 If (choiceOne == yes)
           {
    	System clear;
    	Call askTitle;
            }//If
    D05  Else If (choiceOne == no)
           {
    	System clear;
    	Display I told you so;
    	Call askTitle;
            }//Else If
            Return:
    		
    **************************************/
    void 
    gameRules()
    {
    /*L00*/	char choiceOne;
        
    /*L01*/	printf("                 RULES of MARVIN'S BLACKJACK\n");
    		printf("%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c\n", 
    			spade, spade, heart, club, club, heart, spade, spade, heart, club, club, heart, spade, spade, heart, club, club, heart, spade, spade, heart, 
    			club, club, heart, spade, spade, heart, club, club, heart, spade, spade, heart, club, club, heart, spade,
    			spade, heart, club, club, heart, spade, spade, heart, club, club, heart, spade, spade, heart, club, club, heart, spade, spade, heart, 
    			club, club, heart, spade, spade, heart, club, club, heart, spade, spade, heart, club, club, heart, spade);
    		printf("%c      %c Thou shalt not question the odds of this game.     %c\n", spade, spade, spade);
    		printf("%c      %c This program generates cards at random.            %c\n", spade, spade, spade);
    		printf("%c      %c If you keep losing, you are very unlucky!          %c\n", spade, spade, spade);
    		printf("%c      %c Numbered cards 1 to 10 hold a value of their       %c\n", spade, spade, spade); 
    		printf("%c        number.                                            %c\n", spade, spade, spade);
    		printf("%c      %c J, Q, and K cards hold a value of 10.              %c\n", spade, spade, spade);
    		printf("%c      %c Ace cards hold a value of 1 or 11                  %c\n", spade, spade, spade);
    		printf("%c      %c The goal of this game is to reach a card total     %c\n", spade, spade, spade); 
    		printf("%c        value of 21.                                       %c\n", spade, spade);
    		printf("%c      %c You must place a bet after you receive your        %c\n", spade, spade, spade); 
    		printf("%c        second card.                                       %c\n", spade, spade);
    		printf("%c      %c After the dealing of the first two cards,          %c\n", spade, spade, spade); 
    		printf("%c        YOU must decide whether to HIT or STAY.            %c\n", spade, spade);
    		printf("%c      %c Staying will keep you safe, hitting will add       %c\n", spade, spade, spade);
    		printf("%c        a card.                                            %c\n", spade, spade, spade);
    		printf("%c      %c Because you are competing against the dealer, you  %c\n", spade, spade, spade); 
    		printf("%c        must beat his hand.                                %c\n", spade, spade);
    		printf("%c      %c But play wisely because you will not be able to    %c\n", spade, spade, spade); 
    		printf("%c        see the dealer's first card until his turn.        %c\n", spade, spade);
    		printf("%c      %c BUT BEWARE, if your total goes over 21, you        %c\n", spade, spade, spade);
    		printf("%c        will LOSE!.                                        %c\n", spade, spade);
    		printf("%c      %c If your hand ties the dealers hand at the end      %c\n", spade, spade, spade);
    		printf("%c        of the round, the round ends in a push and you     %c\n", spade, spade);
    		printf("%c        will not win or lose money on your bet.            %c\n", spade, spade);
    		printf("%c      %c But the world is not over, because you can         %c\n", spade, spade, spade); 
    		printf("%c        always play again until you runout of money        %c\n", spade, spade); 
    		printf("%c        before starting a new game.                        %c\n", spade, spade);
    		printf("%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c\n", 
    			spade, heart, club, club, heart, spade, spade, heart, club, club, heart, spade, spade, heart, club, club, heart, spade, spade, heart, 
    			club, club, heart, spade, spade, heart, club, club, heart, spade, spade, heart, club, club, heart, spade,
    			spade, heart, club, club, heart, spade, spade, heart, club, club, heart, spade, spade, heart, club, club, heart, spade, spade, heart, 
    			club, club, heart, spade, spade, heart, club, club, heart, spade, spade, heart, club, club, heart, spade);
    		printf("%c      Would you like to go the start screen? (I will       %c\n", spade, spade);
    		printf("%c                not take NO for an answer)		    %c\n", spade, spade);
    		printf("%c                          (Y/N)        		    %c\n", spade, spade);
    		printf("%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c\n", 
    			spade, heart, club, club, heart, spade, spade, heart, club, club, heart, spade, spade, heart, club, club, heart, spade, spade, heart, 
    			club, club, heart, spade, spade, heart, club, club, heart, spade, spade, heart, club, club, heart, spade,
    			spade, heart, club, club, heart, spade, spade, heart, club, club, heart, spade, spade, heart, club, club, heart, spade, spade, heart, 
    			club, club, heart, spade, spade, heart, club, club, heart, spade, spade, heart, club, club, heart, spade);
    /*L02*/ scanf_s("                                        %c",&choiceOne);
         
    /*L03*/	while((choiceOne != 'Y') && (choiceOne != 'y') && (choiceOne != 'N') && (choiceOne != 'n'))
    	{                                                                           
    		printf("\nIncorrect choice. Please enter Y for Yes or N for No:");
    		scanf_s("\n%c",&choiceOne);
    	}//while
    
    /*L04*/	if((choiceOne == 'Y') || (choiceOne == 'y'))
    	{ 
    		system("cls");
    		askTitle();
    	}//if 
       
    /*L05*/	else if((choiceOne == 'N') || (choiceOne == 'n'))
    	{
    		system("cls");
    		printf("I told you so.\n");
    		askTitle();
    	}//if else
    	return;
    }//gameRules
    
    /*************************************
    DESCRIPTION- gamePlay
    D00 int gamePlayer = 0; 
    	int cardTotal = 1; 
    	char choiceThree;
    
    D01	gameCash = gameCash;
    D02	Call cashTest;
    D03	Display cash; 
    D04	Call randCard; 
    D05	Set playerTotal to gamePlayer plus nextSuite; 
    D06	Set gamePlayer to playerTotal;
    D07	Call dealerFirstCard; 
    D08	Call randCard;
    D09	Set playerTotal to gamePlayer plus nextSuite; 
    D10	Set gamePlayer to playerTotal;
    D11	Display player total;
    D12	Call dealerBot;
    D13	Call gameBetting;
    	 
    	 
    D14	While(cardTotal less than or equal to 21) 
    	{
    D15		If(gamePlayer equals 21)
    		{
    			Display dealer flips last card;
    			Display dealerTotal;
    			Set gameWon to gameWon plus 1;
    			Set gameCash to gameCash plus gameBet;
    			Display you win;
    			Display wins and loses;
    			Set dealerTotal to 0;
    			Call askOver;
    		}//If
        
    D16		If(gamePlayer greater than 21)
    		{
    			Display dealer flips last card;
    			Display dealerTotal;
    			Set gameLoss to gameLoss plus 1;
    			Set gameCash to gameCash minus gameBet;
    			Display you bust;
    			Display wins and loses;
    			Set dealerTotal to 0;
    			Call askOver;
    		}//If
        
    D17		If(gamePlayer Less than or equal to 21)
    		{         
    			Obtain choiceThree;
    
    D18			While((choiceThree!='H') && (choiceThree!='h') && (choiceThree!='S') && (choiceThree!='s'))
    			{                                                                           
    				Display option to hit or stay;
    				Obtain choiceThree);
    				System clear;
    			}//While
    
    D19			If((choiceThree == 'H') || (choiceThree == 'h'))
    			{ 
    				Call randCard;
    				Set playerTotal to gamePlayer plus nextSuite;
    				Set gamePlayer to playerTotal;
    				Display player total
    				Call dealerBot;
    
    D20				If(gamePlayer greater than 21)
    				{
    					Set gameLoss to gameLoss plus 1;
    					Set gameCash to gameCash minus gameBet;
    					Display you bust;
    					Display wins and loses;
    					Set dealerTotal to 0;
    					Call askOver;
    				}//If
    
    D21				If(dealerTotal is equal to 21) 
    				{
    					Display dealer flips last card;
    					Display dealerTotal;
    					Set gameLoss to gameLoss plus 1;
    					Set gameCash to gameCash minus gameBet;
    					Display dealer has a better hand you lose;
    					Display wins and loses;
    					Set dealerTotal to 0;
    					Call askOver;
    				}//if 
         
    D22				If(dealerTotal greater than 21) 
    				{                      
    					Display dealer flips last card;
    					Display dealerTotal;
    					Set gameWon to gameWon plus 1;
    					Set gameCash to gameCash plus gameBet;
    					Display dealer busts you win;
    					Display wins and loses;
    					Set dealerTotal to 0;
    					Call askOver;
    				}//if
    			}//if
    D23			If((choiceThree=='S') || (choiceThree=='s'))
    			{
    				Display you have chosen to stay at playerTotal;
    				Call gameStay;
    			}//If
    		}//While
    D24		cardTotal++; 
    	}//While
    **************************************/
    void 
    gamePlay() 
    {
    /*L00*/	int gamePlayer = 0; 
    		int cardTotal = 1; 
    		char choiceThree;
         
    /*L01*/	gameCash = gameCash;
    /*L02*/	cashTest();
    /*L03*/	printf("Cash: $%d", gameCash); 
    /*L04*/	randCard(); 
    /*L05*/	playerTotal = gamePlayer + nextSuite; 
    /*L06*/	gamePlayer = playerTotal;
    /*L07*/	dealerFirstCard(); 
    /*L08*/	randCard();
    /*L09*/	playerTotal = gamePlayer + nextSuite; 
    /*L10*/	gamePlayer = playerTotal;
    /*L11*/	printf("Your total is %d.\n", gamePlayer);
    /*L12*/	dealerBot();
    /*L13*/	gameBetting();
    	 
    	 
    /*L14*/	while(cardTotal <= 21) 
    	{
    /*L15*/		if(gamePlayer == 21)
    		{
    			printf("The dealer flips his last card over and...\n");
    			printf("The dealer has a total of %d.\n\n", dealerTotal);
    			gameWon = gameWon + 1;
    			gameCash = gameCash + gameBet;
    			printf("You Win!\n");
    			printf("You have %d wins and %d losses.\n", gameWon, gameLoss);
    			dealerTotal = 0;
    			askOver();
    		}//if
         
    /*L16*/		if(gamePlayer > 21)
    		{
    			printf("The dealer flips his last card over and...\n");
    			printf("The dealer has a total of %d.\n\n", dealerTotal);
    			gameLoss = gameLoss + 1;
    			gameCash = gameCash - gameBet;
    			printf("You bust. You lose.\n");
    			printf("You have %d wins and %d losses.\n\n", gameWon, gameLoss);
    			dealerTotal = 0;
    			askOver();
    		}//if
         
    /*L17*/		if(gamePlayer <= 21)
    		{         
    			scanf_s("%c",&choiceThree);
    /*L18*/		                while((choiceThree!='H') && (choiceThree!='h') && (choiceThree!='S') && (choiceThree!='s'))
    			{                                                                           
    				printf("Would you like to Hit or Stay (please enter H to Hit or S to stay)?");
    				scanf_s("%c",&choiceThree);
    				system("cls");
    			}//while
    
    /*L19*/			if((choiceThree == 'H') || (choiceThree == 'h'))
    			{ 
    				randCard();
    				playerTotal = gamePlayer + nextSuite;
    				gamePlayer = playerTotal;
    				printf("Your Total is %d.\n", gamePlayer);
    				dealerBot();
    
    /*L20*/				if(gamePlayer > 21)
    				{
    					gameLoss = gameLoss + 1;
    					gameCash = gameCash - gameBet;
    					printf("You bust. You lose.\n");
    					printf("You have %d wins and %d losses.\n\n", gameWon, gameLoss);
    					dealerTotal = 0;
    					askOver();
    				}//if
    
    /*L21*/				if(dealerTotal == 21) 
    				{
    					printf("The dealer flips his last card over and...\n");
    					printf("The dealer has a total of %d.\n\n", dealerTotal);
    					gameLoss = gameLoss + 1;
    					gameCash = gameCash - gameBet;
    					printf("Dealer has the better hand. You lose.\n");
    					printf("You have %d wins and %d losses.\n\n", gameWon, gameLoss);
    					dealerTotal = 0;
    					askOver();
    				}//if 
         
    /*L22*/				if(dealerTotal > 21) 
    				{                      
    					printf("The dealer flips his last card over and...\n");
    					printf("The dealer has a total of %d and busts.\n\n", dealerTotal);
    					gameWon = gameWon + 1;
    					gameCash = gameCash + gameBet;
    					printf("Dealer has went over! You Win!\n");
    					printf("You have %d wins and %d losses.\n\n", gameWon, gameLoss);
    					dealerTotal = 0;
    					askOver();
    				}//if
    			}//if
    /*L23*/			if((choiceThree=='S') || (choiceThree=='s'))
    			{
    				printf("You have chosen to stay at %d.\n", playerTotal);
    				gameStay();
    			}//if
    		}//while
    /*L24*/		cardTotal++; 
    	}//while
    }//gamePlay
    
    /*************************************
    DESCRIPTION- gameStay
    D00 Call dealerBot;
    D01 If(dealerTotal greater than or equal to 17)
    	{
    D02		If(playerTotal greater than dealerTotal)
    		{
    			Display dealer flips last card;
    			Display dealerTotal;
    			Set gameWon to gameWon plus 1;
    			Set gameCash to gameCash plus gameBet;
    			Display you win;
    			Display wins and loses;
    			Set dealerTotal to 0;
    			Call askOver;
    		}//If
    
    D03		If(playerTotal equals dealerTotal)
    		{
    			Display dealer flips last card;
    			Display dealerTotal;
    			Set gameWon to gameWon plus 0;
    			Set gameCash to gameCash plus 0;
    			Display round ends in a push;
    			Display wins and loses;
    			Set dealerTotal to 0;
    			Call askOver();
    		}//If
    		
    D04		If((playerTotal is less than dealerTotal) && (dealerTotal less than 21))
    		{
    			Display dealer flips last card;
    			Display dealerTotal;
    			Set gameLoss to gameLoss plus 1;
    			Set gameCash to gameCash minus gameBet;
    			Display dealer has a better hand you lose;
    			Display wins and loses;
    			Set dealerTotal to 0;
    			Call askOver;
    		}//If
    		
    D05		If(dealerTotal greater than 21)
    		{
    			Display dealer flips last card;
    			Display dealerTotal;
    			Set gameWon to gameWon plus 1;
    			Set gameCash to gameCash plus gameBet;
    			Display dealer busts you win;
    			Display wins and loses;
    			Set dealerTotal to 0;
    			Call askOver;
    
    		}//If
    	}//If
    D06 Else
        {
    	Call gameStay;
        }//Else
    **************************************/
    void 
    gameStay() 
    {
    /*L00*/	dealerBot();
    /*L01*/	if(dealerTotal >= 17)
    	{
    /*L02*/		if(playerTotal > dealerTotal)
    		{
    			printf("The dealer flips his last card over and...\n");
    			printf("The dealer has a total of %d.\n\n", dealerTotal);
    			gameWon = gameWon + 1;
    			gameCash = gameCash + gameBet;
    			printf("You Win!\n");
    			printf("You have %d wins and %d losses.\n\n", gameWon, gameLoss);
    			dealerTotal = 0;
    			askOver();
    		}//if
    
    /*L03*/		if(playerTotal == dealerTotal)
    		{
    			printf("The dealer flips his last card over and...\n");
    			printf("The dealer has a total of %d.\n\n", dealerTotal);
    			gameWon = gameWon + 0;
    			gameCash = gameCash + 0;
    			printf("The round ends in a push!\n");
    			printf("You have %d wins and %d losses.\n\n", gameWon, gameLoss);
    			dealerTotal = 0;
    			askOver();
    		}//if
    		
    /*L04*/		if((playerTotal < dealerTotal) && (dealerTotal < 21))
    		{
    			printf("The dealer flips his last card over and...\n");
    			printf("The Dealer Has a Total of %d.\n\n", dealerTotal);
    			gameLoss = gameLoss + 1;
    			gameCash = gameCash - gameBet;
    			printf("Dealer has the better hand. You lose.\n");
    			printf("You have %d wins and %d losses.\n\n", gameWon, gameLoss);
    			dealerTotal = 0;
    			askOver();
    		}//if
    		
    /*L05*/		if(dealerTotal > 21)
    		{
    			printf("The dealer flips his last card over and...\n");
    			printf("The dealer has a total of %d and busts.\n\n", dealerTotal);
    			gameWon = gameWon + 1;
    			gameCash = gameCash + gameBet;
    			printf("The dealer went over.  You Win!\n");
    			printf("You have %d wins and %d losses.\n\n", gameWon, gameLoss);
    			dealerTotal = 0;
    			askOver();
    
    		}//if
    	}//if
    /*L06*/	else
    	{
    		gameStay();
    	}//else
    }//gameStay
    
    /*************************************
    DESCRIPTION- clubCard
    
    D00 Set nextCard to rand()%13 + 1;
    D01 If(nextCard is less than or equal to 9)
           {
       	Display number card;
            }//If
        
    D02 If(nextCard is equal to 10) 
           {
    	Display jack;
            }//If
        
    D03 If(nextCard is equal to 11)
           {
       	Display ace;
    		
    D04	If (playerTotal greater than 11)
    	{
    		Set nextCard to 1;
                     }//If
             
    D05           Else
                     {
    		Set nextCard to 11;
                      }//Else
            }//If
        
        
    D06  If(nextCard is equal to 12) 
           {
       	Display queen;
    	Set nextCard to 10;
            }//if
        
    D07 If(nextCard is equal to 13)
           {
    	Display king;
    	Set nextCard to 10;
           }//If
           Return nextCard;
    **************************************/
    int 
    clubCard()
    {
    /*L00*/	nextCard = rand()%13 + 1;
        
    /*L01*/	if(nextCard <= 9)
    	{
       		printf("\n%c%c%c%c%c%c%c\n", 218,196,196,196,196, 196,191);
    		printf("%c%c    %c\n", 179, club, 179);
    		printf("%c  %d  %c\n", 179, nextCard, 179);
    		printf("%c    %c%c\n", 179, club, 179);
    		printf("%c%c%c%c%c%c%c\n\n", 192,196,196,196,196, 196,217);
    	}//if
        
    /*L02*/	if(nextCard == 10) 
    	{
    		printf("\n%c%c%c%c%c%c%c\n", 218,196,196,196,196, 196,191);
    		printf("%c%c    %c\n", 179, club, 179);
    		printf("%c  J  %c\n", 179, 179);
    		printf("%c    %c%c\n", 179, club, 179);
    		printf("%c%c%c%c%c%c%c\n\n", 192,196,196,196,196, 196,217);
    	}//if
        
    /*L03*/	if(nextCard == 11)
    	{
       		printf("\n%c%c%c%c%c%c%c\n", 218,196,196,196,196, 196,191);
    		printf("%c%c    %c\n", 179, club, 179);
    		printf("%c  A  %c\n", 179, 179);
    		printf("%c    %c%c\n", 179, club, 179);
    		printf("%c%c%c%c%c%c%c\n\n", 192,196,196,196,196, 196,217);
    	
    /*L04*/		if (playerTotal > 11)
    		{
    			nextCard = 1;
    		}//if
             
    /*L05*/		else
    		{
    			nextCard = 11;
    		}//else
    	}//if
        
    /*L06*/	if(nextCard == 12) 
    	{
       		printf("\n%c%c%c%c%c%c%c\n", 218,196,196,196,196, 196,191);
    		printf("%c%c    %c\n", 179, club, 179);
    		printf("%c  Q  %c\n", 179, 179);
    		printf("%c    %c%c\n", 179, club, 179);
    		printf("%c%c%c%c%c%c%c\n\n", 192,196,196,196,196, 196,217);
    		nextCard = 10;
    	}//if
        
    /*L07*/if(nextCard == 13)
    	{
    		printf("\n%c%c%c%c%c%c%c\n", 218,196,196,196,196, 196,191);
    		printf("%c%c    %c\n", 179, club, 179);
    		printf("%c  K  %c\n", 179, 179);
    		printf("%c    %c%c\n", 179, club, 179);
    		printf("%c%c%c%c%c%c%c\n\n", 192,196,196,196,196, 196,217);
    		nextCard = 10;
    	}//if
    	return nextCard;           
    }//clubCard
    
    /*************************************
    DESCRIPTION- diamondCard
    
    D00 Set nextCard to rand()%13 + 1;
    D01 If(nextCard is less than or equal to 9)
           {
       	Display number card;
           }//If
        
    D02 If(nextCard is equal to 10) 
           {
    	Display jack;
           }//If
        
    D03 If(nextCard is equal to 11)
           {
       	Display ace;
    		
    D04	If (playerTotal greater than 11)
    	{
    		Set nextCard to 1;
                    }//If
             
    D05	Else
                     {
    		Set nextCard to 11;
                    }//Else
           }//If
        
        
    D06 If(nextCard is equal to 12) 
           {
       	Display queen;
    	Set nextCard to 10;
           }//if
        
    D07 If(nextCard is equal to 13)
           {
    	Display king;
    	Set nextCard to 10;
           }//If
           Return nextCard; 
    **************************************/
    int 
    diamondCard()
    { 
    /*L00*/	nextCard = rand()%13 + 1;
        
    /*L01*/	if(nextCard <= 9) 
    	{
    		printf("\n%c%c%c%c%c%c%c\n", 218,196,196,196,196, 196,191);
    		printf("%c%c    %c\n", 179, diamond, 179);
    		printf("%c  %d  %c\n", 179, nextCard, 179);
    		printf("%c    %c%c\n", 179, diamond, 179);
    		printf("%c%c%c%c%c%c%c\n\n", 192,196,196,196,196, 196,217);
    	}//if
        
    /*L02*/	if(nextCard == 10) 
    	{
    		printf("\n%c%c%c%c%c%c%c\n", 218,196,196,196,196, 196,191);
    		printf("%c%c    %c\n", 179, diamond, 179);
    		printf("%c  J  %c\n", 179, 179);
    		printf("%c    %c%c\n", 179, diamond, 179);
    		printf("%c%c%c%c%c%c%c\n\n", 192,196,196,196,196, 196,217);
    	}//if
        
    /*L03*/	if(nextCard == 11)
    	{
    		printf("\n%c%c%c%c%c%c%c\n", 218,196,196,196,196, 196,191);
    		printf("%c%c    %c\n", 179, diamond, 179);
    		printf("%c  A  %c\n", 179, 179);
    		printf("%c    %c%c\n", 179, diamond, 179);
    		printf("%c%c%c%c%c%c%c\n\n", 192,196,196,196,196, 196,217);
    	
    /*L04*/		if (playerTotal > 11)
    		{
    			nextCard = 1;
    		}//if
             
    /*L05*/		else
    		{
    			nextCard = 11;
    		}//else
    	}//if
        
    /*L06*/	if(nextCard == 12) 
    	{
    		printf("\n%c%c%c%c%c%c%c\n", 218,196,196,196,196, 196,191);
    		printf("%c%c    %c\n", 179, diamond, 179);
    		printf("%c  Q  %c\n", 179, 179);
    		printf("%c    %c%c\n", 179, diamond, 179);
    		printf("%c%c%c%c%c%c%c\n\n", 192,196,196,196,196, 196,217);
    		nextCard = 10; 
    	}//if
        
    /*L07*/	if(nextCard == 13) 
    	{
    		printf("\n%c%c%c%c%c%c%c\n", 218,196,196,196,196, 196,191);
    		printf("%c%c    %c\n", 179, diamond, 179);
    		printf("%c  K  %c\n", 179, 179);
    		printf("%c    %c%c\n", 179, diamond, 179);
    		printf("%c%c%c%c%c%c%c\n\n", 192,196,196,196,196, 196,217);
    		nextCard = 10; 
    	}//if
    	return nextCard;
    }//diamondCard
    
    /*************************************
    DESCRIPTION- gameBetting
    D00	Display enter bet;
    D01	Obtain bet;
    
    D02	If (gameBet > gameCash)
    	{
    		Display error;
    		Display enter bet;
    		Obtain bet;
                                    Return gameBet;
    	}//If
    	
    D03	Else 
    	{
    		Return gameBet;
    	}//Else
    
    **************************************/
    int 
    gameBetting()
    {
    /*L00*/	printf("Enter bet: $");
    /*L01*/	scanf_s("\n%d", &gameBet);
    
    /*L02*/	if (gameBet > gameCash)
    	{
    		printf("You cannot bet more money than you have.\n");
    		printf("Enter Bet: ");
    		scanf_s("\n%d", &gameBet);
                                    return gameBet;
    	}//if
    	
    /*L03*/	else 
    	{
    		return gameBet;
    	}//else
    }//gameBetting
    
    /*************************************
    DESCRIPTION- heartCard
    D00 Set nextCard to rand()%13 + 1;
    D01 If(nextCard is less than or equal to 9)
           {
       	Display number card;
           }//If
        
    D02 If(nextCard is equal to 10) 
           {
    	Display jack;
            }//If
        
    D03 If(nextCard is equal to 11)
           {
       	Display ace;
    		
    D04	If (playerTotal greater than 11)
    	{
    		Set nextCard to 1;
                    }//If
             
    D05          Else
                   {
    		Set nextCard to 11;
                   }//Else
          }//If
        
        
    D06 If(nextCard is equal to 12) 
          {
       	Display queen;
    	Set nextCard to 10;
          }//if
        
    D07 If(nextCard is equal to 13)
           {
    	Display king;
    	Set nextCard to 10;
           }//If
           Return nextCard; 
    **************************************/
    int 
    heartCard() 
    {
    /*L00*/nextCard = rand()%13 + 1;
        
    /*L01*/    if(nextCard <= 9) 
    	{
    		printf("\n%c%c%c%c%c%c%c\n", 218,196,196,196,196, 196,191);
    		printf("%c%c    %c\n", 179, heart, 179);
    		printf("%c  %d  %c\n", 179, nextCard, 179);
    		printf("%c    %c%c\n", 179, heart, 179);
    		printf("%c%c%c%c%c%c%c\n\n", 192,196,196,196,196, 196,217);
    	}//if
        
    /*L02*/	if(nextCard == 10)
    	{
    		printf("\n%c%c%c%c%c%c%c\n", 218,196,196,196,196, 196,191);
    		printf("%c%c    %c\n", 179, heart, 179);
    		printf("%c  J  %c\n", 179, 179);
    		printf("%c    %c%c\n", 179, heart, 179);
    		printf("%c%c%c%c%c%c%c\n\n", 192,196,196,196,196, 196,217);
    	}//if
        
    /*L03*/	if(nextCard == 11)
    	{
    		printf("\n%c%c%c%c%c%c%c\n", 218,196,196,196,196, 196,191);
    		printf("%c%c    %c\n", 179, heart, 179);
    		printf("%c  A  %c\n", 179, 179);
    		printf("%c    %c%c\n", 179, heart, 179);
    		printf("%c%c%c%c%c%c%c\n\n", 192,196,196,196,196, 196,217);
    	
    /*L04*/		if (playerTotal > 11)
    		{
    			nextCard = 1;
    		}//if
             
    /*L05*/                    else
    		{
    			nextCard = 11;
    		}//else
    	}//if
        
    /*L06*/	if(nextCard == 12) 
    	{
    		printf("\n%c%c%c%c%c%c%c\n", 218,196,196,196,196, 196,191);
    		printf("%c%c    %c\n", 179, heart, 179);
    		printf("%c  Q  %c\n", 179, 179);
    		printf("%c    %c%c\n", 179, heart, 179);
    		printf("%c%c%c%c%c%c%c\n\n", 192,196,196,196,196, 196,217);
    		nextCard = 10; 
    	}//if
        
    /*L07*/	if(nextCard == 13)
    	{
    		printf("\n%c%c%c%c%c%c%c\n", 218,196,196,196,196, 196,191);
    		printf("%c%c    %c\n", 179, heart, 179);
    		printf("%c  K  %c\n", 179, 179);
    		printf("%c    %c%c\n", 179, heart, 179);
    		printf("%c%c%c%c%c%c%c\n\n", 192,196,196,196,196, 196,217);
    		nextCard = 10; 
    	}//if
    	return nextCard;
    }//heartCard
    
    /*************************************
    DESCRIPTION- randCard
    D00	Set randomCard to rand()%4 + 1;
         
    D01 If(randomCard equals 1)
           {   
                  Call clubCard;
                  Set nextSuite to nextCard;
           }//If
         
    D02 If(randomCard equals 2)
          {
                Call diamondCard;
                Set nextSuite to nextCard;
          }//If
         
    D03 If(randomCard equals 3)
           {
                 Call heartCard;
                 Set nextSuite to nextCard;
            }//If
             
    D04 If(randomCard == 4)
           {
                   Call spadeCard;
                   Set nextSuite to nextCard;
           }//If    
           Return nextSuite;
    **************************************/
    int 
    randCard() 
    { 
    /*L00*/	randomCard = rand()%4 + 1;
         
    /*L01*/	if(randomCard == 1)
    	 {   
    		clubCard();
    		nextSuite = nextCard;
    	}//if
         
    /*L02*/	if(randomCard == 2)
    	{
    		diamondCard();
    		nextSuite = nextCard;
    	}//if
         
    /*L03*/	if(randomCard == 3)
    	{
    		heartCard();
    		nextSuite = nextCard;
    	}//if
             
    /*L04*/	if(randomCard == 4)
    	{
    		spadeCard();
    		nextSuite = nextCard;
    	}//if    
    	return nextSuite;
    }//randCard
    
    /*************************************
    DESCRIPTION- spadeCard
    D00 Set nextCard to rand()%13 + 1;
    D01 If(nextCard is less than or equal to 9)
           {
       	Display number card;
            }//If
        
    D02 If(nextCard is equal to 10) 
            {
    	 Display jack;
            }//If
        
    D03 If(nextCard is equal to 11)
           {
       	Display ace;
    		
    D04	If (playerTotal greater than 11)
    	{
    		Set nextCard to 1;
                    }//If
             
    D05	 Else
                     {
    		Set nextCard to 11;
                      }//Else
            }//If
        
        
    D06 If(nextCard is equal to 12) 
           {
       	Display queen;
    	Set nextCard to 10;
           }//if
        
    D07 If(nextCard is equal to 13)
          {
    	Display king;
    	Set nextCard to 10;
          }//If
          Return nextCard;
    **************************************/
    int 
    spadeCard() 
    { 
    /*L00*/	nextCard = rand()%13 + 1;
        
    /*L01*/ if(nextCard <= 9) 
    	{
    		printf("\n%c%c%c%c%c%c%c\n", 218,196,196,196,196, 196,191);
    		printf("%c%c    %c\n", 179, spade, 179);
    		printf("%c  %d  %c\n", 179, nextCard, 179);
    		printf("%c    %c%c\n", 179, spade, 179);
    		printf("%c%c%c%c%c%c%c\n\n", 192,196,196,196,196, 196,217);
    	}//if
        
    /*L02*/	if(nextCard == 10) 
    	{
    		printf("\n%c%c%c%c%c%c%c\n", 218,196,196,196,196, 196,191);
    		printf("%c%c    %c\n", 179, spade, 179);
    		printf("%c  J  %c\n", 179, 179);
    		printf("%c    %c%c\n", 179, spade, 179);
    		printf("%c%c%c%c%c%c%c\n\n", 192,196,196,196,196, 196,217);
    	}//if
        
    /*L03*/	if(nextCard == 11) 
    	{
    		printf("\n%c%c%c%c%c%c%c\n", 218,196,196,196,196, 196,191);
    		printf("%c%c    %c\n", 179, spade, 179);
    		printf("%c  A  %c\n", 179, 179);
    		printf("%c    %c%c\n", 179, spade, 179);
    		printf("%c%c%c%c%c%c%c\n\n", 192,196,196,196,196, 196,217);
    		
    /*L04*/		if (playerTotal > 11)
    		{
    			nextCard = 1;
    		}//if
             
    /*L05*/                   else
    		{
    			nextCard = 11;
    		}//else
    	}//if
        
    /*L06*/ if(nextCard == 12) 
    	{
    		printf("\n%c%c%c%c%c%c%c\n", 218,196,196,196,196, 196,191);
    		printf("%c%c    %c\n", 179, spade, 179);
    		printf("%c  Q  %c\n", 179, 179);
    		printf("%c    %c%c\n", 179, spade, 179);
    		printf("%c%c%c%c%c%c%c\n\n", 192,196,196,196,196, 196,217);
    		nextCard = 10; 
    	}//if
        
    /*L07*/	if(nextCard == 13)
    	{
    		printf("\n%c%c%c%c%c%c%c\n", 218,196,196,196,196, 196,191);
    		printf("%c%c    %c\n", 179, spade, 179);
    		printf("%c  K  %c\n", 179, 179);
    		printf("%c    %c%c\n", 179, spade, 179);
    		printf("%c%c%c%c%c%c%c\n\n", 192,196,196,196,196, 196,217);
    		nextCard = 10;
    	}//if
    	return nextCard;
    }//spadeCard
    //BlackjackFMJ.c
    Last edited by mjf_03; 04-24-2011 at 02:51 PM. Reason: alignment was slightly off

  2. #2
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Good luck getting it to compile!

    That code's worth exactly what you paid for it...
    (Ain't it funny how scoop and poop coding always turns out that way)

  3. #3
    Registered User
    Join Date
    Apr 2011
    Posts
    4
    It compiles just fine and if you want me to send you the original .c file to add to it or make changes let me know at my email mjf_03@yahoo.com.
    Last edited by mjf_03; 04-24-2011 at 02:54 PM.

  4. #4
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by mjf_03 View Post
    You obviously didn't look at it. It works just fine and if you want me to send you the .c file email me at mjf_03@yahoo.com.
    No sir... I won't be sending you anything. Nice try though.
    phantomotap likes this.

  5. #5
    Master Apprentice phantomotap's Avatar
    Join Date
    Jan 2008
    Posts
    4,332
    No sir... I won't be sending you anything. Nice try though.
    O_o

    Seriously. If he came to brag about his code, wanting an email to send the code to is awfully suspect.

    Soma

  6. #6
    Registered User
    Join Date
    Apr 2011
    Posts
    4
    I wasnt bragging about anything I just wanted so get some useful feed back to improve what I have but obviously im mistaken and so far everyone has been less than helpful so I'm just wasteing my time here.

    So thankyou sirs for the very insightful feedback I'm sure I'm a much better programmer because of it.
    Last edited by mjf_03; 04-24-2011 at 02:44 PM.

  7. #7
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,659
    Here are my thoughts.

    1. The block comments at the start of each function are far too detailed. For a large program, you should generally assume a level of competence above clueless newbie. Clueless newbies need these kinds of comments, but they also need much smaller programs to get to grips with.

    2. Not a single function takes any parameters at all. The four xxxCard functions could all be reduced to a single function with the simple addition of a parameter.

    3. Because you have no parameters, you're stuck with messy global variables.

    4. What prevents something like nextCard = rand()%13 + 1; from dealing the same card twice? Especially since you made a point of fixing a card dealing bug.
    There are plenty of examples on the board where the idea of a 'deck' is coded, which can be shuffled and cards drawn from it. This ensures randomness and non-repetitiveness which one would expect from a deck of cards.

    5. askOver and gamePlay call each other recursively. Use a loop in say main() to call each in turn, and make each function return a useful status that can be acted on. Given enough time, this will blow the call stack (a lot easier than you might think if you're still messing with TurboC).

    6. gameBetting only checks the bet amount once.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  8. #8
    Registered User
    Join Date
    Apr 2011
    Posts
    4
    Thanks for the input I will look into your suggestions, Salem.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Need Help With a BlackJack Program in C
    By Jp2009 in forum C Programming
    Replies: 15
    Last Post: 03-30-2009, 10:06 AM
  2. Simple Blackjack Program
    By saber1357 in forum C Programming
    Replies: 1
    Last Post: 03-28-2009, 03:19 PM
  3. blackjack program
    By mackieinva in forum C Programming
    Replies: 8
    Last Post: 09-20-2007, 03:46 AM
  4. Help with Blackjack program
    By sugie in forum C++ Programming
    Replies: 1
    Last Post: 04-30-2005, 12:30 AM
  5. BlackJack Program...
    By 67stangman in forum C++ Programming
    Replies: 3
    Last Post: 05-06-2002, 10:44 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21