i just started to learn C++ , and come across 2 exercises in C++ Primer . 1 of this exercises i can't understand .
Exercise 2.22 C++ Primer
if (p) //....
if (*p) //....
int *p = NULL;
checks whether p is NULL or not and will return false.
(*p) == 0, i.e. the integer pointed by
p is 0 or not.
if you have
i.e., without initializing it, then
p will point to random address in your memory, and
will most of the time return true. and
will give undefined behavior.