liveBook · Manning

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.

How 3 Manning books explain it

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.

Read how Modern C explains null pointer constant →

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

Related concepts

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.