Is NULL always equal to 0(zero)? Ans. The answer depends on what you mean by 'equal to.' If you mean 'compares equal to,' such as if ( /* ... */ ) { p = NULL; } else { 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.) - Study24x7
Social learning Network

Warning: include(./views/auth.php): failed to open stream: Permission denied in /var/www/html/live/loginRightSlider.php on line 18

Warning: include(): Failed opening './views/auth.php' for inclusion (include_path='.:/usr/share/php') in /var/www/html/live/loginRightSlider.php on line 18

Warning: count(): Parameter must be an array or an object that implements Countable in /var/www/html/live/makepost.php on line 52
05 Apr 2023 12:56 PM study24x7 study24x7

Is NULL always equal to 0(zero)? Ans. The answer depends on what you mean by "equal to." If you mean "compares equal to," such as if ( /* ... */ ) { p = NULL; } else { p = /* something else */; } /* ... */ if ( p == 0 ) then yes, NULL is always equal to 0. That's the ...

See more

study24x7
Write a comment
Related Questions
500+   more Questions to answer
Most Related Articles