1NULL(3const)                                                      NULL(3const)
2
3
4

NAME

6       NULL - null pointer constant
7

LIBRARY

9       Standard C library (libc)
10

SYNOPSIS

12       #include <stddef.h>
13
14       #define NULL  ((void *) 0)
15

DESCRIPTION

17       NULL  represents  a null pointer constant, that is, a pointer that does
18       not point to anything.
19

CONFORMING TO

21       C99 and later; POSIX.1-2001 and later.
22

NOTES

24       The  following  headers  also  provide  NULL:  <locale.h>,   <stdio.h>,
25       <stdlib.h>, <string.h>, <time.h>, <unistd.h>, and <wchar.h>.
26

CAVEATS

28       It  is  undefined behavior to dereference a null pointer, and that usu‐
29       ally causes a segmentation fault in practice.
30
31       It is also undefined behavior to perform pointer arithmetic on it.
32
33       NULL - NULL is undefined behavior, according to ISO C, but  is  defined
34       to be 0 in C++.
35
36       To  avoid  confusing  human readers of the code, do not compare pointer
37       variables to 0, and do not assign 0 to them.  Instead, always use NULL.
38
39       NULL shouldn't be confused with NUL, which is  an  ascii(7)  character,
40       represented in C as '\0'.
41

BUGS

43       When it is necessary to set a pointer variable to a null pointer, it is
44       not enough to use memset(3) to zero the pointer (this is  usually  done
45       when  zeroing  a  struct that contains pointers), since ISO C and POSIX
46       don't guarantee that a bit pattern of all 0s represent a null  pointer.
47       See  the EXAMPLES section in getaddrinfo(3) for an example program that
48       does this correctly.
49

SEE ALSO

51       void(3type)
52
53
54
55Linux man-pages 6.04              2023-02-05                      NULL(3const)
Impressum