ISO C++ forbids comparison between pointer and integer

when I use gcc to compile this .c file, there's no exception, but when I use g++ to compile, it throw below error:
ch.c: In function `int get(int*)':
ch.c:5: error: ISO C++ forbids comparison between pointer and integer
ch.c:5: error: operands to ?: have different types

the code is as below:



int get(int *ot){
int a=10;
int c=0;
c=(ot>a?ot:a);
return c;
}

int main(){
int t=1000;
int cc=0;
cc=get(&t);
return 0;
}

how can I do if need g++ to compile this .c file? thanks.
What do you want the code to do? You don't want to compare a pointer address to an integer, do you?
There is an of course about that !

You can't compare a pointer with another datatype !

The job you can do is to get the value of that pointer (i think you should use *pointer_name , not sure) and then compare the value with the number.

Topic archived. No new replies allowed.