Connect four advice needed!

Hi guys, i'm currently trying to create connect four in C++, however i'm having a little trouble discerning why my win check going vertical declares a winner despite four in a row not being played, but simply four of the same counter in that column in any order, is declared a winner. Any help is greatly appreciated for my little problem.

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
 //vertical win for player one
	do
	{
		
	if (gameboard[wrow][col] == 'X')
	{
	colwin++;
	}
	wrow++
	}
	while (wrow<7 && colwin<4);

	if (colwin==4)
	{
    cout<<name1<<" has won!"<<endl;
	winner=true;
	
	}

	// vertical win for player two
	do
	{
		if (gameboard[wrow2][col] == 'O')
		{
		colwin2++;
		}
		wrow2++;
	}
	while (wrow2<7 && colwin2<4);

	if (colwin2==4)
	  {
	  cout<<name2<<" has won!"<<endl;
	  winner=true;
The problem is on line 5: You need an else case where you reset colwin = 0;

It'd be a good idea to put the while loops in one function.
Thank you very much! I know my code is a little messy, Thrown myself into the deep end a little bit with this, but i appreciate your help, thank you.
Topic archived. No new replies allowed.