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 2 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 compile-time null pointer constants from pointer objects holding null values and guides portable use of `NULL`.
How deep it goes
Defines the pre-C23 forms, examines permissible `NULL` expansions, and sketches a conditional-expression test without providing its completed macro.
Examples
Uses two `const` pointer objects, possible `NULL` expansions, and a conditional expression whose type distinguishes qualifying expressions.
What you can do after
Evaluate/understand whether a pre-C23 expression qualifies as a null pointer constant and why `NULL` may hide a type choice.

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 →

Related concepts

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.