In c language. What happens when we subtract Null pointer from char *
int i = (char *)a - (char *)0;
In c language. What happens when we subtract Null pointer from char *
int i = (char *)a - (char *)0;
Pointer difference is defined only for two pointers that both point into or just past the end of the same array (where a pointer to a non-array object is considered as if it were a pointer to a one-element array). By definition, a null pointer does not point to any object, therefore no pointer difference involving a null pointer has defined behavior. Not even the difference between two null pointers.