Null object: Difference between revisions

Content added Content deleted
(→‎{{header|C}}: These header files define NULL.)
(→‎{{header|C}}: Move a sentence from Undefined values#C that fits better here.)
Line 96:
Classic BASIC does have the concept of un-initialised or undefined variables.
=={{header|C}}==
C has the null pointer. By convention, it points to memory address zero. ThereIt is a(supposedly) verygaranteed commonto macrobe pointing to nothing, so receiving one of those likely means you are not looking at an object--<codei>NULLbut</codei>, whichthere evaluatesare tooccasions where changing content of a null pointer actually does something <code>(void*)say, 0</code>on orDOS); anand equivalenta value.function NULLthat's issupposed compatibleto withreturn alla pointer types,on includingsuccess bothdoesn't dataalways pointersreturn anda function0 pointersotherwise (e.g. mmap returns -1 for failure).
 
There is a very common macro, <code>NULL</code>, which evaluates to <code>(void*) 0</code> or an equivalent value. NULL is compatible with all pointer types, including both data pointers and function pointers.
 
The standard library defines NULL in locale.h, stddef.h, stdio.h, stdlib.h, string.h, time.h and wchar.h. [[POSIX]] systems also define NULL in dirent.h and unistd.h. Many C files include at least one of these headers, so NULL is almost always available.