trouble with pointers

I am trying to use certain variables accross multiple functions so I have used pointers and it works accross the majority of my code but when I get to the function that calls all the other functions and acctually runs the program it tells me that the identifyers are undefined
maybe if you could elaborate or post some code, it will be easier for people to help
this is where the problems are arising
1
2
3
4
5
6
7
8
9
10
11
12
13
while (checkEndGame == 0 && numTurn < 9)
	{
		askMove(*mref);
		verifyMakeMove(gameBoard,BOARD_SIZE, *pref, *mref);
		printBoard(gameBoard,BOARD_SIZE);
		if (*pref = 1)
		{
			*pref ++;
		}
		else
		{
			*pref --;
		}

this is the declaration of the pointer
1
2
int player = 1;
int* pref = &player;
how are your function declarations set up?
like this
bool verifyMakeMove(char gameBoard[],int BOARD_SIZE, int& mref, int& pref);
is that the function code for the code above?
no the above code is part of
int playGame();
but playGame's main purpose is simply calling the other functions in a specific order
since arrays are pointers, you could simply pass gameBoard as a pointer and take the address of that..? i dunno it looks fine to me
there are no problems with gameBoard its mref and pref they give me this error message
Error	5	error C2065: 'pref' : undeclared identifier

and seven others the same one for each time they're mentioned in that loop and I dont see why considering they work throughout the rest of the program
could it be something to do with the order in which the functions are called and when the pointers are declared
I am really hoping that its a simple mistake causeing this something that dosent require me to go back and completely re-code the program
closed account (1vRz3TCk)
jax666999 wrote:
error C2065: 'pref' : undeclared identifier
Does the error message not tell you enough? There is no identifier in scope that is called pref.

Also:
your function declarations is using references not pointers;

the order that you are calling the parameters look different to the order they are declared;

and you may want to look at if (*pref = 1), I don't think that that is what you want to be doing.
Topic archived. No new replies allowed.