#include <cmath>
#include <iostream>
#include <fstream>
#include <iomanip> 

using namespace std;

bool InitializeBoard(int** connectNBoard,  int numRowsInBoard );
bool MakeMove(int** connectNBoard, int numRowsInBoard,  int player, int columnChosen);
bool DisplayBoard( int** connectNBoard,  int numRowsInBoard);
bool CheckWinner( int** connectNBoard, int numRowsInBoard, int numConnect, int columnChosen, int player);

int main()
{
	int numRows, numToConnect, maxMove, counter;
	bool check, check2;

	cout <<"Please enter size of the board between 8~25";
	cin  >>numRows;
	if(numRows<8 || numRows>25)
	{
		cout <<"You have entered a wrong value. Please enter the value again";
		cin  >>numRows;
	}
	cout <<"Please enter a value for the player to win the game (numbers to connect) between  4 <= numToConnect <= numRows - 4 ";
	cin  >>numToConnect;
	cout <<endl;
	if(numToConnect <4 || numToConnect> (numRows-4))
	{
		cout <<"You have entered a wrong value. Please enter the value again";
		cin  >>numToConnect;
	}
	int **myConnectNBoard;
	myConnectNBoard = new int*[numRows];
	for (int i=0; i<numRows; i++)
	{		
		myConnectNBoard[i] = new int[numRows];
	}
	
	check =	InitializeBoard(myConnectNBoard, numRows);
	if (check==false)
	{
		cout<<"Initialization was not done proerply";
		return 1;
	}

	check2 = DisplayBoard(myConnectNBoard,numRows);
	if (check==false)
	{
		cout<<"Diaplaying of the board was not done proerply";
		return 1;
	}
	maxMove= numRows*numRows;
	for(counter=0; counter<maxMove/2; counter++)
	{
		if(counter%2 ==0)
		{
			cout<<"Red Moves"<<endl;
		}
		else
		{
			cout<<"Black Moves"<<endl;
		}
	}




	
	















}

bool InitializeBoard(int** connectNBoard,  int numRowsInBoard)
{
	int i,j;
	for(i=0; i<numRowsInBoard; i++)
	{
		for(j=0; j<numRowsInBoard; j++)
		{
			connectNBoard[i][j]=0;
		}
	}
	return true;
}
bool DisplayBoard( int** connectNBoard,  int numRowsInBoard)
{
	int i,j;
	cout<<"   ";
	for (i=0; i<numRowsInBoard; i++)
	{
		cout <<setw(3)<<i;
	}
	cout<<endl;

	for(i=0; i<numRowsInBoard; i++)
	{
		cout<<setw(3)<<i;
		for(j=0; j<numRowsInBoard; j++)
		{
			cout<<setw(3) <<connectNBoard[i][j];
		}
		cout<<endl<<endl;
	}
	return true;
}
bool MakeMove(int** connectNBoard, int numRowsInBoard,  int player, int columnChosen)
{
	cout<<"Enter the column you want to enter your piece";
	cin>>columnChosen;
	if(columnChosen>numRowsInBoard || connectNBoard[i][j] !=0 || columnChosen<0 || )
	{
		cout <<"Illegal Move";
		return false;
	}

I have written here so far. The currently problem that I am facing is that I have no idea how I can write the MakeMove function. I am totally stuck and can't even think of a way to insert a move and not sure how I am going to insert move alternating Black player and Red Player and I am also confused how I am going to check whether if there's already a game piece in there or not. Can anyone help me?

After taking nothing more than a glance at your program I assume these answers will solve your problem:

1) "Insert" one of two players' colour in the board would be, for example, putting Board[j] = 1 for player 1 or = 2 for player 2.
2) Hold a variable Turn = 0 and increment it after every move. (Turn%2)+1 will tell you which player has to move
3) If Board[j]==0 then that slot is empty, otherwise it's occupied

Hope this helps :)

Think of the connect 4 as tic tac toe but different algorithm in finding the winner.

1-You would print the board
2-prompt player 1 for position on the board he wants
3-Let player 1 have 'X' and player 2 have 'O' or '1' or '2' or w/e character you want
print that character on to the position of the board
4-re print the board
5-check if winner - should check when the move count is reasonable to have a winner
6-prompt player 2 choice
7-reprint
8-check for winner

If you have a 4x4 board, you would have 16 slots.
Make an array of 16 integers instantiate them to -1 or 0
when either player inserts a move put a '1' or '2' to mark the players choice
that array would be used to check for winner and check to see which position is occupied.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.