Mail Archives: djgpp/2013/08/01/08:47:30
> A NULL pointer can and does point to accessable memory for most C
> compilers.
It's not the compiler that decides this, it's the operating system.
Many operating systems do not map the first page of memory, so a NULL
pointer may not point to accessible memory.
> Typically, this is pointer or address to memory location zero, but
> it's not required to be. It can be *any* value as long as no other
> C object has that same address.
"An integer constant expression with the value 0, or such an
expression cast to type void *, is called a null pointer constant."
So, it's zero now.
> If NULL's type is a void pointer, it is (losslessly) converted to a char
> pointer when passed into a function for a char pointer argument. I.e.,
> after the conversion, it functions as a char pointer in the function.
"A string is a contiguous sequence of characters terminated by and
including the first null character."
So there's a difference between "char pointer" and "pointer to a
string". atoi() takes a pointer to a string. Not all char pointers
are pointers to strings.
"If a null pointer constant is converted to a pointer type, the
resulting pointer, called a null pointer, is guaranteed to compare
unequal to a pointer to any object or function."
Since a pointer to any valid string cannot be equal to the null
pointer, a null pointer cannot point to a string.
- Raw text -