Hello
I have a variable Player1Visits which is declared as int
If I try to compare this to 1 using Player1Visits == 1 I get the warning comparison between integer and pointer. Should I be using a different type?
Paul
Hello
I have a variable Player1Visits which is declared as int
If I try to compare this to 1 using Player1Visits == 1 I get the warning comparison between integer and pointer. Should I be using a different type?
Paul
I would double-check what Player1Visits is declared as; if you're getting that compiler warning, it is almost certainly not an int
. Likely possibilities include what @aronchick said, where Player1Visits is an int*
(a pointer to an int), so you want to compare using:
*Player1Visits == 1
Another possibility is that Player1Visits is some kind of object with an int
property, where you want to figure out what property name you want and call:
[Player1Visits someIntProperty] == 1
(This last assumes you're using Objective-C, which is (I believe) a not-unreasonable assumption given your choice of IDE.)
ok now I am getting a new problem for this! I get a crash when I try to compare using *Player1Visits == 1
Appears as though Player1Visits is 0x0 even though I have set it to 0 by doing both *Player1Visits = 0 and also trying Player1Visits = 0
Do I have to allocate memory for an int variable as well? If so what is the syntax? Will be so glad when I get the hang of this language! At the moment I am managing the difficult bits but getting stumped on things that should be easy!
You haven't declared it as int
, the compiler warning gives that away. Perhaps you've declared it as NSInteger *Player1Visits;
or int *Player1Visits;
.
If you declared it that way, remove the *
.