Question: I keep getting error messages in this program. Could I get some help debugging this c++ code: #include using namespace std; int main() { void

I keep getting error messages in this program. Could I get some help debugging this c++ code:

#include

using namespace std;

int main() {

void showBoard(void); void playerInput(int p); void checkWinner(); void nextPlayer(int);

int board_info[7][7] = { {0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0}, }; int _tmain(int argc, _TCHAR* argv[]) { int r; int c; int player; int winner; int turns; cout << "******* 7X7 Board Game *******" << endl; showBoard(); nextPlayer(1); return 0;

}

void showBoard(void) { int r; int c; cout << endl << endl; cout <<"\tColumns "; cout <<"\t123 "; for(r=0; r<=6; r++) { cout << "Row " << (r+1) << ": "; for(c=0; c<=6; c++) { if(board [r][c]==0) cout << "*"; else if (board [r][c]==1) cout << "X"; else cout << "0 "; } cout << endl; }

}

void playerInput(int p) // Function for choosing a move by a player { int row; int col; if (p==1) cout <<" Player 1, place player1 choice in the game board "; else cout <<" Player 2, place player2 choice in the game board ";

cout <<"Enter Row " ; cin >> row; cout <<"Enter Column "; cin >> col;

if(p==1) board[--row][--col]-1; if(p==2) board[--row][--col]-2;

}

void checkWinner() // Function for declaring winner of the game

{

int winner; for (int i=0; i<-6; i++) { if(board[i][0]==board[i][1] && board[i][1]==board[i][2] && board[i][2]==board[i][3] && board [i][3]==board[i][4] && board[i][4]==board[i][5] && board[i][5]==board[i][6] && board[i][0]!=0)

{ winner=board[i][0];

}

}

for(int i=0; i<=6; i++) { board[0][i]==board[1][i] && board[1][i]==board[2][i] && board[2][i]==board[3][i] && board [3][i]==board[4][i] && board[4][i]==board[5][i] && board[5][i]==board[6][i] && board[0][i]!=0 { winner=board[0][i];

}

}

if(board[0][0]==board[1][1] && board[1][1]==board[2][2] && board[2][2]==board[3][3] && board [3][3]==board[4][4] && board[4][4]==board[5][5] && board[5][5]==board[6][6] && board[0][0]!=0)) { winner=board[0][0]; }

if(board[0][2]==board[1][1] && board[1][1]==board[2][0] && board[0][4]==board[2][2] && board [2][2]==board[4][0] && board[0][6]==board[3][3] && board[3][3]==board[6][0] && board[0][2]!=0)

{ winner=board[0][2];

}

if(board[0][0]==board[0][1] && board[0][1]==board[0][2] && board[0][2]==board[0][1] && board [1][0]==board[1][1] && board[1][1]==board[1][2] && board[1][2]==board[2][0] && board[2][0]==board[2][1] && board[2][1]==board[2][2] && board[0][0]!=0)

{ winner=0;

}

void nextPlayer(int player) { playerInput(player); showBoard();

if(player==1) player=2;

else player=1; nextPlayer(player); }

}

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!