buffer overrun problem

Hi: For a programming assignment I am required to deal out two poker hands and determine which one is the best. The assignment gave me some code to start with below, that writes out both hands. What I want to be able to do is store one hand in one array, and the second hand in another, but I keep getting this buffer overrun error after the program executes.
deck is a 4by13 integer array representing a deck of cards, with row headers as the suit, and column headers as the face value. they have been pre-shuffled.
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
//initialize suit array
	static const char *suit[4] = {
		"Hearts", 
		"Diamonds", 
		"Clubs", 
		"Spades"
	};
	//initialize face array
	static const char *face[13] = {
		"Ace",
		"Deuce",
		"Three",
		"Four",
		"Five",
		"Six",
		"Seven",
		"Eight",
		"Nine",
		"Ten",
		"Jack",
		"Queen",
		"King"
	};
	//MODIFICATION-->only need 10 cards dealt
	int g = 0;
	for (int card = 1; card <= 10; card ++)
	{
		//loop through rows of deck
		for (int row = 0; row <= 3; row ++)
		{
			//loop through columns of deck for current row
			for (int column = 0; column <= 12; column ++)
			{
				//if slot contains current card, display card
				if (deck[row][column] == card)
				{
					cout << setw(5) << right << face[column] << " " << column << "" << " of ";
					cout << setw(8) << left << suit[row];
					/*hands[g] = column;*/
					/*g++;*/
					if (card % 2 == 0)
					{
						cout << endl;
                                                //store the column number (face value) in player1 array
						player1[g] = column;
                                                //increment the counter
						g++;
					}
					else
					{
						cout << "\t";
                                                //store the column number (face value) in player2 array
						player2[g] = column;
						g++;
					}
					
				}
			}
		}
	}
Last edited on
Never mind I figured out a solution on my own. I would help if the textbook had given me proper code to begin with.
Topic archived. No new replies allowed.