Trouble With Black Jack

This is a discussion on Trouble With Black Jack within the C Programming forums, part of the General Programming Boards category; I am taking a programming class this semester for the first time and my final assignment is to write a ...

  1. #1
    Registered User
    Join Date
    May 2011
    Posts
    2

    Trouble With Black Jack

    I am taking a programming class this semester for the first time and my final assignment is to write a console program to play Black Jack. What I have right now won'y work and I'm not sure where to go from here. Any input offered would be much appreciated.

    *the first problem is :fatal error C1083: Cannot open include file: 'cstdlib.h': No such file or directory

    Code:
    #include <stdio.h>
    #include <string.h>
    #include <cstdlib.h>
    
    Struct card
    
    { char rank [15];
    
    char suit [15];
    
    int value;
    };
    
    typedef struct card Card;
    
    int main ()
    
    {char deck [52];
    
    char ranks [13] [15]={"ace", "king", "queen", "jack", "ten", "nine", "eight", "seven", "six", "five", "four", "three", "two"};
    
    char suit [4] [15]={"hearts", "diamonds", "spades", "clubs"};
    
    int values [13]= {11, 10, 10, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2};
    
    int i, player=0, top=0;
    
    for(i=0; i<52; i++)
    
    {strcpy(deck[i].rank, ranks[i%13]);
    
    strcpy(deck[i].suit, suits[i%4]);
    
    deck[i].value=values[i%13]);
    
    card c= deck[top++]
    
    printf("your first card is %s of %s \n", c.rank, c.suit);
    
    player= c.value;
    
    deck=[top++];
    
    printf("dealer showing %s of %s \n", c.rank, c.suit);
    
    dealer=c.value;
    
    c=deck[top++]
    
    printf("your second card is %s of %s", c.rank, c. suit);
    
    player=player+c.value;
    
    c=deck[top++];
    
    dealer=dealer+c.value;
    
    printf("another card");
    
    scanf("%s", answer);
    
    while(strcmp(answer, "yes")==0)
    
    //give more cards
    
    	while (dealer<17)
    	{
    	//give more cards
    
    if(player>dealer)
    	
    	printf("you win! \n");
    
    return 0;
    	}}}
    struct player
    
    {char name[30];
    
    int count;
    
    card hand [12];
    
    double cash;
    
    double bet;
    
    };
    typedef struct player player;
    
    	struct aDeck;
    
    	{int top;
    
    	card deck[52];
    	};
    	typedef struct aDeck Deck;
    	
    		char ranks[13][15]={"Ace","King","Queen","Jack","Ten","Nine","Eight","Seven","Six","Five","Four","Three","Two"};
    
    	int main()
    	
    	{Player me, dealer;
    	
    	deck.myDeck;
    	
    	int i;
    	
    	for(i=0,i=52,i++)
    	
    	{strepy(myDeck.deck[i].rank,ranks[i%13]);
    	
    	strepy(myDeck.deck[i].suit,suits[i%4]);
    	
    	myDeck.deck[i].value=value[i%13];
    	}
    		char suits[4][15]={"Spades","Hearts","Clubs","Diamonds"};
    	
    	int values[13]={11,10,10,10,10,9,8,7,6,5,4,3,2};
    
    	printf("how much cash?");
    	
    	scanf("%1f",&me.cash);
    	
    	printf("place your bet");
    	
    	scanf("%1f",&me.bet);
    	
    	printf("what is your name?");
    	
    	gets(me.name);
    	
    	c=mydeck.deck[top++];
    	
    	me.count=0;
    	
    	printf("%s your first card is %s of %s \n", me.name,c.rank,c.suit);
    	
    	me.hand[count++]=c;
    	
    	c=myDeck.deck[top++];
    	
    	printf("Dealer's first card is %s \n",  c.rank, c.suit);
    	
    	dealer.count=0;
    	
    	dealer.deck[count++]=c;
    	
    		//another card for player and dealer
    	
    		printf("more cards");
    	
    	scanf("%s", answer);
    	
    	while(string(answer,"yes")==0)
    	{
    		c=myDeck.deck[top++];
    	
    		printf("%s your next card is %s of %s \n", me name, c.rank, c.suit;);
    	
    		me.hand[count++]=c;
    		}
    	
    		//adding up cards
    	
    	total hand=0;
    	
    		for(i=0,i<dealer.count;i++)
    		
    		{totalHand=totalHand+dealer.hand[i].value;};
    
    			int totalHand(Player p)
    		
    		{int total=0
    		
    		int i;
    		
    		for(int=o;i<p.count;i++)
    		
    			total=total+p.hand[i].value;
    		
    		return total;
    		}

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Quote Originally Posted by robo92321 View Post
    Any input offered would be much appreciated.

    *the first problem is :fatal error C1083: Cannot open include file: 'cstdlib.h': No such file or directory

    Code:
    #include <stdio.h>
    #include <string.h>
    #include <cstdlib.h>
    Do you c where the problem is?


    Quzah.
    Hope is the first step on the road to disappointment.

  3. #3
    Registered User
    Join Date
    May 2011
    Posts
    2
    Thank you for pointing that out. It seems a very silly mistake in hindsight. The error is no longer appearing.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Need help with black jack
    By cuo741 in forum C++ Programming
    Replies: 1
    Last Post: 09-22-2010, 01:17 AM
  2. Black Jack Game
    By AwesomeMMan in forum C Programming
    Replies: 2
    Last Post: 05-22-2009, 10:19 AM
  3. Making Black Jack
    By xeler8tor in forum C Programming
    Replies: 2
    Last Post: 12-14-2008, 03:13 AM
  4. Black Jack
    By marquis1431 in forum C Programming
    Replies: 1
    Last Post: 05-06-2008, 04:30 PM
  5. Help with Black Jack Game
    By Frantic- in forum C++ Programming
    Replies: 5
    Last Post: 02-03-2005, 08:16 PM

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