comparison between pointer and integer problem

With thhe following bit of code I always get the error of:

ISO C++ forbids comparison between pointer and integer

/////////////////////////////////////////////////////////
char setValue[4];
fread(&setValue, sizeof(char), 1, buttonHandle);
fclose(buttonHandle);
if (setValue == 1){
////////////////////////////////////////////////////////

I have tried it with this also but still get the same error:
if (setValue == '1'){

I know that if I use the next bit of code, that is where I should get this error.

if (setValue == "1"){

The value of setValue will always be either a zero or a one
Last edited on
In your code, you've declared the 'setValue' identifier as an array of four characters.
In your if-statement, you are not specifying which particular element of the array you're comparing, so setValue simply gets interpreted as a pointer to the memory address of the first element in the array.
Also don't forget about the apostrophes.

I'm not sure in what context your code is applied, but here's an example :
if(setValue[0] == '1') {/*code*/}

Hope this clarified things.
Oh, it is an array. Now I understand. My code now does compile. Thank you for your support, it is greatly appreciated.
Last edited on
Topic archived. No new replies allowed.