Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Hello. I keep getting errors when I try to test out the beginning of my Tic Tac

ID: 3640665 • Letter: H

Question

Hello. I keep getting errors when I try to test out the beginning of my Tic Tac Toe program using Netbeans:

***************************************************
main.cpp:7: error: 'SIZE' was not declared in this scope
main.cpp:8: error: 'SIZE' was not declared in this scope
main.cpp:10: error: 'SIZE' was not declared in this scope
main.cpp:12: error: 'SIZE' was not declared in this scope
main.cpp: In function 'int main()':
main.cpp:17: error: uninitialized const 'SIZE'
main.cpp:19: error: assignment of read-only variable 'SIZE'
main.cpp: At global scope:
main.cpp:37: error: 'SIZE' was not declared in this scope
main.cpp:42: error: 'SIZE' was not declared in this scope
main.cpp: In function 'void DisplayBoard()':
main.cpp:45: error: 'SIZE' was not declared in this scope
main.cpp:56: error: 'board' was not declared in this scope
main.cpp: At global scope:
main.cpp:86: error: 'SIZE' was not declared in this scope
main.cpp:96: error: 'SIZE' was not declared in this scope
main.cpp: In function 'char CheckWin()':
main.cpp:100: error: 'SIZE' was not declared in this scope
main.cpp:102: error: 'ar' was not declared in this scope
make[2]: *** [build/Debug/GNU-MacOSX/main.o] Error 1
make[1]: *** [.build-conf] Error 2
make: *** [.build-impl] Error 2

BUILD FAILED (exit value 2, total time: 383ms)
***************************************************

I'm not sure what I am doing wrong! I've declared all of the variables and functions. I realize the functions aren't complete yet. I'm just trying to display the instructions and the board but it wont run! Below is the program:

********************************************************************
#include <iostream>
#include <iomanip>
#include <string>
using namespace std;

void OutputInstruct();
void InitBoard(char board[][SIZE]);
void DisplayBoard(const char board[][SIZE]);
void GetPlayers(string& player1, string& player2);
void GetAndCheckInp(char board[][SIZE], char token, string player1, string player2);
char SwitchToken(char token);
char CheckWin(const char board[][SIZE]);
void OutputWinner(char whoWon, bool tied, string player1, string player2);

int main()
{
const int SIZE;
char board;
SIZE = 3;

OutputInstruct();
DisplayBoard(board[][SIZE]);

return 0;
}

void OutputInstruct()
{
cout << "Welcome to Tic Tac Toe! Here is how you play: ";
cout << "jdksfksjkfnsfnksdjks fdsfjsdnfsd fsdjfdsf sfsndf ";
cout << "jsfnjsdn sdf jsnf sdfsdjkf jsdk fjksd fjsd fjsdjjk ";
}

void InitBoard(char board[][SIZE])
{

}

void DisplayBoard(const char board[][SIZE])
{
cout << setw(10) << "1" << setw(8) << "2" << setw(9) << "3 ";
for (int row = 0; row < SIZE; row++)
{

cout << setw(10) << "[1][" << row+1 << "] | " << "[2][" << row+1;
cout << "] | " << "[3][" << row+1 << "]" << endl;
cout << setw(14) << "|" << setw(9) << "|" << endl;

for (int col = 0; col < SIZE; col++)
{
switch(col)
{
case 0: cout << row + 1 << setw(9) << board[col][row];
cout << setw(4) << "|";
break;

case 1: cout << setw(4) << board[col][row];
cout << setw(5) << "|";
break;

case 2: cout << setw(4) << board[col][row] << endl;
break;

default: cout <<"ERROR! ";
}
}

cout << setw(14)<< "|" << setw(10) << "| ";

if (row != 2)
{
cout << setw(32) << "-------------------------- ";
}
}
cout << endl << endl;
}

void GetPlayers(string& player1, string& player2)
{

}

void GetAndCheckInp(char board[][SIZE], char token, string player1, string player2)
{

}

char SwitchToken(char token)
{

}

char CheckWin(const char board[][SIZE])
{
bool win = false;

for(int col = 0; col < SIZE; col++)
{
if(ar[col][0] != ' ' && ar[col][0] == ar[col][1] && ar[col][0] == ar[col][2])
{
return ar[col][0];
}
}
}

void OutputWinner(char whoWon, bool tied, string player1, string player2)
{

}
********************************************************************

Thanks in advance

Explanation / Answer

#include <iostream>
#include <iomanip>
#include <string>
using namespace std;

const int SIZE = 3;   // declare this variable here and re run your program.