Is there any difference between null
and NULL
?
I know null character ('\0'
) other than that any co-relation between them ?
Asked
Active
Viewed 98 times
-7

Surya Prakash Patel
- 711
- 6
- 14
-
Related, if not a duplicate to: http://stackoverflow.com/q/1296843/694576 – alk Apr 11 '16 at 17:32
-
Yes. If you use the wrong one, you get warnings and/or errors. – Martin James Apr 11 '16 at 17:32
-
2C and C++ are different languages. When asking about something, it is in general a good idea to provide the necessary definitions and use markdown. – too honest for this site Apr 11 '16 at 17:33
-
"null" does not exist in the C language. – Lee Daniel Crocker Apr 11 '16 at 19:30
1 Answers
6
NULL
is a macro that yields a null pointer constant (typically a plain, unadorned 0
or 0L
in C++, and ((void *)0)
in C). In modern C++, nullptr
is usually the preferred way to get a null pointer constant though.
NUL
is the ASCII designation for a zero-byte. The C standard calls this a "null character".
"null" is a normal word. In C++, its primary use is as part of the phrase "null pointer" (or "null pointer constant").

Jerry Coffin
- 476,176
- 80
- 629
- 1,111
-
In C++, using `NULL` or `0` is deprecated. Use `nullptr` instead. Not sure about C++, but in C, `\0` is also a _null pointer constant_. It should not be used just by convention. – too honest for this site Apr 11 '16 at 17:34
-
1and `0LL`, `0ULL`, `0U`, `0UL` and `0x0000000` and `00`, `(1+2-3)` and `(7 / 3 - 2)` are all *null pointer constants* in C. – Antti Haapala -- Слава Україні Apr 11 '16 at 17:42
-
"null" is also used extensively in C as part of _null character_: `'\0'`. – chux - Reinstate Monica Apr 11 '16 at 17:59