As we stated earlier, we never concern ourselves about the specific value of a pointer. However, we can carry out comparison operations on pointers for the following:
- Is a pointer equal or not equal to NULL?
- Is a pointer equal to or not equal to a named location?
- Is one pointer equal or not equal to another pointer?
In each case, we can either check for equality (==) or inequality (!=). Because we can never be certain of the variable ordering in memory, it makes no sense whatsoever to test whether one pointer is greater than (>) or less than (<) another pointer.
If we consistently apply the guideline to always assign a value to a pointer, even if that value is NULL, we can then make the following comparisons:
if( pDimension == NULL ) printf( "pDimension points to nothing!\n" );
if( pDimension != NULL ) printf( "pDimension points to something!\n" );
The first...