Jump to content

Null object: Difference between revisions

→‎{{header|C}}: These header files define NULL.
(→‎{{header|C}}: These header files define NULL.)
Line 96:
Classic BASIC does have the concept of un-initialised or undefined variables.
=={{header|C}}==
C's accesshas tothe null ispointer. byBy wayconvention, ofit points to memory address zero. There is a very common macro, which<code>NULL</code>, simplywhich 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.
 
<lang c>#include <stdio.h>
 
#include <stdlib.h>
int main()
if (object == NULL) {
{
printf("object is null");
char *object = 0;
 
if (object == NULL) {
printf puts("object is null");
}
return 0;
}</lang>
 
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.