On this page
NULL
Prev: ptrdiff_t | Up: stddef.h | Next: offsetof
Rel: stddef.h, stdint, stdbool & limits Guide
Ref: cppreference — NULL
Tags: #public #prog #c #stdlib #stddef #tier/core
Include
#include <stddef.h>
Signature & Overview
#define NULL /* null pointer constant */
Null pointer constant for C11/C17 (C23 adds type-safe nullptr).
Notes & Pitfalls
- Always initialize pointers to
NULLand reset afterfree(p); p = NULL;: In C23, prefernullptr.
Example
#include <assert.h>
#include <stddef.h>
int main(void) {
int *p = NULL;
assert(p == NULL);
}
Linked from
Related notes
- tuts/c/stdlib/stddef/offsetof Linked here; links to this page; shared tags: #c, #prog, #stddef, #stdlib, #tier
- tuts/c/stdlib/stddef/ptrdiff_t Linked here; links to this page; shared tags: #c, #prog, #stddef, #stdlib, #tier
- tuts/c/stdlib/stddef Linked here; links to this page; shared tags: #c, #prog, #stddef, #stdlib
- tuts/c/builtins/nullptr links to this page; shared tags: #c, #prog, #tier
- tuts/c/stdlib/stdint_stdbool_and_limits Linked here; shared tags: #c, #prog, #stdlib
- tuts/c/stdlib/stddef/max_align_t shared tags: #c, #prog, #stddef, #stdlib, #tier
- tuts/c/stdlib/stddef/size_t shared tags: #c, #prog, #stddef, #stdlib, #tier
- tuts/c/stdlib/assert/assert shared tags: #c, #prog, #stdlib, #tier
- tuts/c/stdlib/assert/static_assert shared tags: #c, #prog, #stdlib, #tier
- tuts/c/stdlib/ctype/isalpha shared tags: #c, #prog, #stdlib, #tier