calling functions

my function calls aren't working this is where most of them are
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
	char gameBoard [BOARD_SIZE];
	clearBoard(gameBoard,BOARD_SIZE);

	while (checkEndGame == 0 && numTurn < 9)
	{
		askMove(mref);
		verifyMakeMove(gameBoard,BOARD_SIZE, mref, pref);
		printBoard(gameBoard,BOARD_SIZE);
		if (*pref = 1)
		{
			*pref ++;
		}
		else
		{
			*pref --;
		}
		checkEndGame(gameBoard,BOARD_SIZE);
		numTurn++;
	}

the code compiles and then just tells me the result of the game at first I thaught it might be something to bo with the functions themselves so I put a break point in the middle of the askMove function and it never reached that break point so my functions arent running I figure that this is something to do with the calls
post the entire program please.
are you sure the program is split accross three files all up its probably about 400 lines
my best guess is that the declaration of the function or the parameters is filled incorrectly or declared after the function is used. but no way to tell.
this is my header file containing constants and function declarations
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include <iostream>
#include <string>
using namespace std;

const char P1_CHAR = 'X';
const char P2_CHAR = 'O';
const char FREE_CHAR = '_';
const int BOARD_SIZE = 9;
const int BOARD_WIDTH = 3;



void clearBoard(char gameBoard[],int BOARD_SIZE);

int playGame();

void printBoard(char gameBoard[],int BOARD_SIZE);

int checkEndGame(char gameBoard[],int BOARD_SIZE);

int askMove(int *mref);

bool verifyMakeMove(char gameBoard[],int BOARD_SIZE, int* mref, int* pref);
the array size needs to be const so make
int board_size
const int board_size
Last edited on
const int BOARD_SIZE = 9;
is the array size it is a const int
int checkEndGame(char gameBoard[],int BOARD_SIZE);

char gameBoard [BOARD_SIZE];
I went through and changed int BOARD_SIZE to const int BOARD_SIZE in all the function declarations it didnt fix the problem they still dont call
There was no reason to make that change. Your function parameters probably shouldn't hide your global constants though (they should have different names.)

int checkEndGame(char gameBoard[],int BOARD_SIZE);

while (checkEndGame == 0 && numTurn < 9)

CheckEndGame is a function. When you compare it to 0 you're comparing the address of the function to 0, and that will never be true.



I was trying to compare its return value to 0 if == uses its address how do I use its return value
You call it.

while ( 0 == checkEndGame(gameBoard, BOARD_SIZE) && numTurn < 9 )
Topic archived. No new replies allowed.