cplusplus
.com
TUTORIALS
REFERENCE
ARTICLES
FORUM
user name:
password:
Forgot your password?
please wait
try again
cancel
forgot your password?
sign up
log in
[Legacy version]
C++
Tutorials
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs
Forum
Beginners
About null
About null
Sep 6, 2008 at 3:13am
Sep 6, 2008 at 3:13am UTC
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 ?
Sep 6, 2008 at 3:27am
Sep 6, 2008 at 3:27am UTC
Zhuge
(4664)
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.
Sep 7, 2008 at 1:18am
Sep 7, 2008 at 1:18am UTC
helios
(17607)
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."
Topic archived. No new replies allowed.