Interview answers verified by specialists.

Find interview questions and answers on this website:

See right interview answers on 30 common job interview questions

Is NULL always equal to 0(zero)?

The answer depends on what you mean by "equal to." If you mean "compares equal to," such as

if ( /* ... */ )
     p = NULL;
     p = /* something else */;
/* ... */
if ( p == 0 )

then yes, NULL is always equal to 0. That's the whole point of the definition of a null pointer.

If you mean "is stored the same way as an integer zero," the answer is no, not necessarily. That's the most common way to store a null pointer. On some machines, a different representation is used.

The only way you're likely to tell that a null pointer isn't stored the same way as zero is by displaying a pointer in a debugger, or printing it. (If you cast a null pointer to an integer type, that might also show a nonzero value.)

Do you know that?

24% - I began freelancing after geing downsized Next


Fast Payments
Payoneer sing up to get free