A little background on the problem I'm encountering with my program. In this program the user enters the column number that they wish to play in and I am having problems on the error checking part. I had the normal "out of bounds" checking fine, but when I tried to add in the "if column is full" check I ran into an error. My logic could be wrong, or maybe I am missing something because I'm tired
--- I've narrowed it down to the check full function not increasing 'A' for some reason in my for loop, I THINK
Get column number function:
// This function receives a column from the user
// checks the validity and then places the mark
void getCol(char boardArray[6][7], char playerMark)
{
int a = 6;
int col = 0;
// Asks for colmn number
cout << "Choose a colmn: ";
cin >> col;
// Data check
while (col < 0 || col > 6 || checkCol(boardArray, playerMark, col) == true)
{
cout << "Invalid Input!" << endl;
cout << "Choose a colmn: ";
cin >> col;
}
// Loops through all colmns
for (int b = 0; b < 7; b++)
// Checks colmn chosen
if (col == B)/>
{
while (boardArray[a][b] != '-')
a--;
boardArray[a][b] = playerMark;
}
}
Check if column is full function:
// This function checks to see if the column is full and
// the the column number matches. If it does true is returned.
bool checkCol(char boardArray[6][7], char playerMark, int col)
{
for (int a = 0; a < 7; a++)
{
cout << "COL: " << col << endl;
cout << "A : " << a << endl;
if (boardArray[0][a] == playerMark && col == a)
{
cout << "TRUE" << endl;
return true;
}
else
{
cout << "FALSE" << endl;
return false;
}
}
}

New Topic/Question
Reply



MultiQuote





|