cplusplus.com cplusplus.com
cplusplus.com   C++ : Forums : Beginners : About null
  Search:
- -
C++
Information
Documentation
Reference
Articles
Sourcecode
Forums
Forums
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Articles
Lounge
Jobs

-

post  About null

dnrsimha23 (1)
Sir what is null.what does it represent in c and c++? Is it a keyword or identifier ? What value does it contain ?
|
Zhuge (102)
I am fairly certain the standard says NULL is the following:
1
2
3
4
5
6
7
#ifndef NULL
 #ifdef __cplusplus
  #define NULL  0
 #else
  #define NULL  ((void *)0)
 #endif
#endif 

So in C++, NULL is 0, and in C NULL is 0 casted to a void pointer.
|
helios (829)
Actually, the value of NULL is system-dependent. 0, however, is guaranteed by the standard to be an invalid pointer in any system. So 0 and NULL are equivalent (they are both invalid pointers), but NULL may not equal 0.

"When in doubt, set it to zero."
|

This topic is archived - New replies not allowed.
Home page | Privacy policy
© cplusplus.com, 2000-2008 - All rights reserved - v2.2
Spotted an error? contact us