I am trying to determine the purpose of checking for a pointer being greater than 0:
void someFunction(int *src) {
int val = *src++;
if( val > 0 ) {
// Do something?
}
}
If the data type is pointer, wouldn’t the value of the pointer always be a memory address? Does doing pointer arithmetic do something that may set val = 0 ?
Is this a simple null pointer check?
That’s not checking if a pointer is greater than zero; it’s checking if the pointed-to value is greater than zero, and simultaneously advancing the pointer by one. Here’s some equivalent code that might help you understand:
valis just anint, not a pointer.