Poker game in C?

This is the code I have and I don't know why nothing is showing up when i run it. I'm a beginner so i'm sorry if it's a dumb question. It's as if its not running the analyzeHand function and i don't know why. There is random code that won't fit in the question so i didn't include it. I just want to know if i called the function correctly.

#include <stdio.h>

#include <stdlib.h>

void analyzeHand (int facesInHand[], int suitsInHand[]);

int main(){

 int facesInHand[13], suitsInHand[4];

 int num;

 int i = 0;

 while(i<5){

  num=rand()%13;

  facesInHand[num]+=1;

  num=rand()%4;

  suitsInHand[num]+=1;

 }

 analyzeHand (facesInHand, suitsInHand);

}

void analyzeHand(int facesInHand[], int suitsInHand[])

{

*RANDOM CODE*

 if (straight && flush)

  printf("Straight flush\n\n");

 else if (four)

  printf("Four of a kind\n\n");

 else if (three && pairs == 1)

  printf("Full house\n\n");

 else if (flush)

  printf("Flush\n\n");

 else if (straight)

  printf("Straight\n\n");

 else if (three)

  printf("Three of a kind\n\n");

 else if (pairs == 2)

  printf("Two pairs\n\n");

 else if (pairs == 1)

  printf("Pair\n\n");

 else

  printf("High card\n\n");

}

3 Answers

Relevance
  • Mike W
    Lv 7
    10 months ago

    There seems to be an awful lot missing from the programme.  Your while loop is basically an infinite loop.  

  • EddieJ
    Lv 7
    10 months ago

    Your code doesn't seem to make any sense.

    There are 13 faces in a deck, not in a hand.

    You aren't incrementing <i> so it's stuck in an infinite loop.

  • Anonymous
    10 months ago

    did you try debugging?

Still have questions? Get your answers by asking now.