problems with poker

hi, I have a poker program. I am trying to determine when there is a pair in the hand dealt. I just can't get it to work, I'm not sure where I'm going wrong if anyone could help point me in the right direction that would be great. thanks. (I was just trying to match a pair of aces to see if i was on the right track, so far I'm not)




1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#include <stdio.h>
#include <stdlib.h>
#include <time.h>

void shuffle( int wDeck[][13]);
void deal(const int wDeck[][13], const char *wFace[],
		  const char *wSuit[]);
void pair(const int wDeck[][13]);


int main()
{
	
	const char *suit[4] = { "Hearts", "Diamonds", "Clubs", "Spades"};

	const char *face[13] =
	{ "Ace", "Two", "Three", "Four", "Five",
	"Six", "Seven", "Eight", "Nine", "Ten", 
	"Jack", "Queen", "King"};

	int deck[4][13]= {0};

	srand( time(0));

	shuffle(deck);
	deal(deck, face, suit);
	pair(deck);
	
	return 0;
}

/*shuffle cards in deck*/
void shuffle(int wDeck[][13])
{
	int row;
	int column;
	int card;

		for (card = 1; card <= 52; card++){

		
		do{
			row = rand() % 4;
			column = rand() % 13;
		}while( wDeck[ row][column] !=0);

		/* place card in chosen slot */
		wDeck[ row] [column] = card;
	}
}

void deal ( const int wDeck[] [13], const char *wFace[],
		   const char *wSuit[])

{
	int card;
	int row;
	int column;

	/* deal 5 cards */

	for (card = 1; card <= 5; card++){

		/* loop through rows of wDeck */
		for (row = 0; row <= 3; row++){

			/*loop through columns of wDeck for current row */
			for ( column = 0; column <= 12; column++){

				/* if slot contains current card, display card */
				if (wDeck[row][column] == card){
				printf("%-5s of %-8s%\n", wFace[column], wSuit[row]);
			
			}
		}
	}
}
	printf("\n");
}

void pair(const int wDeck[][13])
{
	
	int row;
	int column;
	int pair[13] = {0};

	
		for (row = 0; row <= 3; row++){
		for ( column = 0; column <= 12; column++){

			if(wDeck[row][0] == 1){
				pair[0]++;
			}
		}
		}
		if( pair[0]== 2){
			printf("A pair of Aces");
		}

}
What is the meaning of this line?
if(wDeck[row][0] == 1)

also, what is the purpose of this line in pair()? You never actually use column for anything.
for ( column = 0; column <= 12; column++){
I was trying to search through the deck to find the selceted cards, but have tried various ways and i think I have just confused myself totally.
Thanks for pointing out the looping of column, I've sorted it now so I can go on to altering it so that I can do the same for evey pair that occurs. Thank u. Heres what I did.
1
2
3
4
5
6
7
8
9
10
	for (row = 0; row <= 3; row++){
	
			if(wDeck[row][0] > 0){
				pair[0]++;
			}
		}
		
		if (pair[0]==2){
			printf("A pair of Aces!\n");
		}
Topic archived. No new replies allowed.