Null pointer constant
A null pointer constant is a language-defined zero-valued or null-pointer expression that can be converted to a null pointer.
Modern C, Third Edition
A pre-C23 null pointer constant is a compile-time constant expression of integer type and value zero or an expression of type void* that can be converted to a null pointer.
- How it is used
- Distinguishes expressions that qualify as null pointer constants from pointer objects whose values are null.
- How deep it goes
- Defines pre-C23 forms, contrasts compile-time constants with const-qualified objects, and notes that NULL's type is unspecified.
- Examples
- Compares 0, 0L, and (void*)0 as possible NULL expansions and describes type-based detection with generic selection.
- What you can do after
- Evaluate/understand which pre-C23 expressions qualify and why NULL can conceal type differences.
Read how Modern C, Third Edition explains null pointer constant →
Modern C
A null pointer constant is an integer constant expression with value zero or such a value converted to void pointer, as permitted by the C standard.
- How it is used
- Clarifies how zero-valued constants represent null pointers and why NULL is unsafe in variadic interfaces.
- How deep it goes
- Defines permitted types, distinguishes compile-time constants from const objects, and traces NULL into variadic-call failures.
- Examples
- Uses const pointer declarations, permitted NULL expansions, and a printf call demonstrating variadic type mismatch.
- What you can do after
- Evaluate null-pointer spellings and avoid NULL where its unspecified type can compromise portability.
100 C++ Mistakes and How to Avoid Them
A null pointer constant is an integer constant expression or pointer value that can be converted to a null pointer.
- How it is used
- Shows how NULL can mislead readers and produce unintended overload selection or unsafe checks after deletion.
- How deep it goes
- Demonstrates overload selection with code and gives a practical fix for pointers after deletion.
- Examples
- Uses overloaded `compute` calls and a deleted `Person` pointer to illustrate misuse and safer nulling.
- What you can do after
- Diagnose/debug with it by checking NULL’s type when overload selection matters and nulling pointers after deletion.
Read how 100 C++ Mistakes and How to Avoid Them explains null pointer constant →
What to know first
- missing valueA missing value is an expected data value or observation that is absent, unavailable, unknown, or inapplicable.
- referenceA reference is an indirect value, binding, or relationship that identifies or provides access to another object, value, resource, or source.
- void pointerA void pointer is a C pointer of type void* that can hold the address of an object without specifying its pointed-to object type.
Related concepts
- macrokind of · A macro is a named, reusable construct that expands into generated code or a sequence of commands when invoked, often during preprocessing, compilation, or application execution.
- missing valuealternative to · A missing value is an expected data value or observation that is absent, unavailable, unknown, or inapplicable.
- referencecontrasts with · A reference is an indirect value, binding, or relationship that identifies or provides access to another object, value, resource, or source.
- constantcontrasts with · A constant is a value or named program binding defined or treated as fixed, though whether reassignment or mutation is prohibited depends on the language.
- void pointeruses · A void pointer is a C pointer of type void* that can hold the address of an object without specifying its pointed-to object type.
- implicit conversioncontrasts with · An implicit conversion is an automatic change of a value from one type or representation to another, performed according to language or library rules without explicit conversion syntax at the use site.
Questions about null pointer constant
What is null pointer constant?
A null pointer constant is a language-defined zero-valued or null-pointer expression that can be converted to a null pointer.
Which Manning books explain null pointer constant?
Modern C, Third Edition, Modern C and 100 C++ Mistakes and How to Avoid Them.
What should I know before learning null pointer constant?
Manning books that teach null pointer constant usually introduce missing value, reference and void pointer first.
What is the difference between null pointer constant and missing value?
A null pointer constant is a language-defined zero-valued or null-pointer expression that can be converted to a null pointer. A missing value is an expected data value or observation that is absent, unavailable, unknown, or inapplicable.
What is null pointer constant a kind of?
Null pointer constant is a kind of macro. A macro is a named, reusable construct that expands into generated code or a sequence of commands when invoked, often during preprocessing, compilation, or application execution.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.


