a value indicating that a pointer does not refer to a valid object
In computing, a null pointer (sometimes shortened to nullptr or null) or null reference is a value indicating that the pointer or reference does not refer to an object. Programs routinely use … Wikipedia
🌐
Wikipedia
en.wikipedia.org › wiki › Null_pointer
Null pointer - Wikipedia
2 days ago - In Java and C#, the literal null is provided as a literal for reference types. In Pascal and Swift, a null pointer is called nil. In Eiffel, it is called a void reference. In Rust, the absence of a value is denoted as None, but a true null pointer is std::ptr::null().
🌐
IBM
ibm.com › docs › en › i › 7.5.0
Null pointers - IBM Documentation
September 29, 2025 - A null pointer constant with the nullptr value has the following characteristics: It can be converted to any pointer or pointer-to-member type. It cannot be implicitly converted to any other type, except for the bool type.
Discussions

Trying to understand NULL pointers
NULL is equivalent to 0 and equivalent to nullptr (in C++). It's an address that is "universally invalid." You can store 0x2093704802934 in a pointer and it will be invalid too (I'm sure) but it's not a convention. NULL is this convention that says "the pointer is not valid" and/or "the pointer hasn't been initialized yet" or "the memory pointed to has been released and I have invalidated the pointer by setting it to NULL." You store this value in a "pointer", like "int* s = 0" to show that it is not pointing to anything. And in your code you will check whether the pointer (s in my example) is equal to NULL (invalid) or not (valid). First you create a pointer, then you initialize it, then you use it, then you release it. More on reddit.com
🌐 r/learnprogramming
18
1
December 30, 2021
C++ What are the NULL pointer values? - Stack Overflow
And yet, I've never heard of any architecture where NULL pointer has a value that does not consist of all 0 bits. 2013-05-30T06:06:44.263Z+00:00 ... What if you type cast and integer of value 0 to a pointer and assign that? At that point it is out of the compiler's hands, what would happen? More on stackoverflow.com
🌐 stackoverflow.com
Checking for null pointers when 0 is a valid address
Don't use MCUs designed by crazy people. More on reddit.com
🌐 r/embedded
56
33
October 17, 2023
Question: Why are NULL pointers so ridiculously hated?
Looking at it the other way around, what advantage does the use of null provide over an option/result type? More on reddit.com
🌐 r/ProgrammingLanguages
90
0
May 25, 2023
People also ask

Can a null pointer be assigned to any data type?
Yes, a null pointer can be assigned to any pointer variable, regardless of its data type. This flexibility is because the null pointer doesn’t point to any actual data, but rather a special memory value, often zero. However, the interpretation of null pointers can vary slightly depending on the programming language, so caution should be exercised when implementing cross-language solutions.
🌐
lenovo.com
lenovo.com › home
Null Pointer in Programming – Definition, Uses, and Common Pitfalls ...
Can a null pointer be compared with other pointers?
Yes, null pointers can be compared to other pointers. This is a common practice to ensure that a pointer has been assigned a valid memory address. For example, checking whether a pointer is null before accessing it helps programmers avoid dereferencing errors. Such comparisons are straightforward and widely used in safe memory management.
🌐
lenovo.com
lenovo.com › home
Null Pointer in Programming – Definition, Uses, and Common Pitfalls ...
What is the difference between a null pointer and an uninitialized pointer?
A null pointer explicitly points to “nothing” and holds a defined null value, like zero, while an uninitialized pointer contains garbage or unpredictable data. Unlike null pointers, uninitialized pointers pose a significant risk of leading the program to access invalid memory, potentially causing serious errors.
🌐
lenovo.com
lenovo.com › home
Null Pointer in Programming – Definition, Uses, and Common Pitfalls ...
🌐
Lenovo
lenovo.com › home
Null Pointer in Programming – Definition, Uses, and Common Pitfalls | Lenovo US
A null pointer is a special type of pointer in programming that points to no valid memory location or object. It is used to indicate that the pointer doesn’t contain a usable or meaningful memory address.
🌐
cppreference.com
en.cppreference.com › cpp › types › nullptr_t
std::nullptr_t - cppreference.com
August 11, 2024 - std::nullptr_t is the type of the null pointer literal nullptr. It is a distinct type that is not itself a pointer type or a pointer to member type.
🌐
GeeksforGeeks
geeksforgeeks.org › c language › null-pointer-in-c
NULL Pointer in C - GeeksforGeeks
The Null Pointer is the pointer that does not point to any location but NULL. According to C11 standard: “An integer constant expression with the value 0, or such an expression cast to type void *, is called a null pointer constant.
Published   January 10, 2025
🌐
GeeksforGeeks
geeksforgeeks.org › c++ › null-pointer-in-cpp
NULL Pointer in C++ - GeeksforGeeks
In modern C++, nullptr is the preferred ... it is type-safe. We can check whether a pointer is a NULL pointer by using the equality comparison operator. ... The above expression will return true if the pointer is a NULL pointer. False otherwise. Null pointers serve several important purposes in C++, from safe initialization of pointers to ...
Published   1 week ago
Find elsewhere
🌐
Reddit
reddit.com › r/learnprogramming › trying to understand null pointers
r/learnprogramming on Reddit: Trying to understand NULL pointers
December 30, 2021 -

Hello all again,

I have another stupid question here lol, so I'm trying to wrap my head around NULL. Im currently under the impression that NULL is a built in constant that has a value of zero, but what does that actually mean? When would it be appropriate to use null? If someone could explain it in layman's terms that would be super helpful!

🌐
Microsoft Learn
learn.microsoft.com › en-us › cpp › extensions › nullptr-cpp-component-extensions
nullptr (C++/CLI and C++/CX) | Microsoft Learn
June 25, 2025 - The nullptr keyword is not a type and is not supported for use with: ... The nullptr keyword can be used to test if a pointer or handle reference is null before the reference is used.
🌐
Unstop
unstop.com › home › blog › null pointer in c | a detailed explanation with examples
Null Pointer In C | A Detailed Explanation With Examples
May 3, 2024 - They allow us to access and manipulate ... are four main types of pointers in the C programming language: null pointer, void pointer, wild pointer, and dangling pointer....
Top answer
1 of 4
8

The 0xCACACACA generated by Visual Studio is usually there for un-initialized pointers, for precisely this reason. When you see this, you know something is wrong. If it initialized it to 0, it can very well be expected behavior. This is only done in debug node, with full optimization the value of an uninitialized pointer would be just garbage.

And yes, NULL pointers don't have a value of 0 per say. 0 is just a literal. The actual value can be different. But the compiler is smart enough to abstract that away, so even if you have a NULL pointer whose value isn't really 0 (as in the number 0), comparing it to 0 or NULL would still yield true. It's better to think in terms of nullptr really.

2 of 4
4

This question previously appeared on the comp.lang.c newsgroup. You can read the archive with Google Groups

In that thread, Paul Sand quoted another source, "Portable C" by H. Rabinowitz and Chaim Schaap, as follows:

Certain Prime computers use a value different from all-bits-0 to encode the null pointer. Also, some large Honeywell-Bull machines use the bit pattern 06000 to encode the null pointer. On such machines, the assignment of 0 to a pointer yields the special bit pattern that designates the null pointer.

Similarly, (char *)0 yields the special bit pattern that designates a null pointer.

Where you'd commonly see non-null pointers is when working with physical memory addresses (that is, when there is no MMU or in kernel mode bypassing the MMU) and the machine has memory-mapped I/O at or near address 0. You want a null pointer to be way out in no-man's land, so that if you offset it (e.g. structure member access via a pointer) you won't get any useful address.

For your specific question, only an integral constant expression with value 0 is interpreted as a null pointer. So

char* p = (char*)i;

does not portably make p a null pointer (i.e. the Standard makes no such guarantee, but your particular compiler may).

🌐
ScienceDirect
sciencedirect.com › topics › computer-science › null-pointer
Null Pointer - an overview | ScienceDirect Topics
In short, black is a meaningful default, null is a meaningless but not invalid default for pointers, and Image 21 is typically an invalid default for numbers—or at least this summarizes typical usage patterns. Unpacking the conceptual variations between different type-instances—meaningful, meaningless, and invalid defaults, for instance, or literal-initializable values—gives rise to a sense of types' “extensional space”; how there are (sometimes) patterns and groupings amongst type-values more specific than just being instances of their respective types.
🌐
cppreference.com
en.cppreference.com › cpp › types › NULL
NULL - cppreference.com
January 3, 2025 - In C, the macro NULL may have the type void*, but that is not allowed in C++ because null pointer constants cannot have that type. Run this code · #include <cstddef> #include <iostream> #include <type_traits> #include <typeinfo> class S; int main() { int* p = NULL; int* p2 = static_cast<std::nullptr_t>(NULL); void(*f)(int) = NULL; int S::*mp = NULL; void(S::*mfp)(int) = NULL; auto nullvar = NULL; // may trigger a warning when compiling with gcc/clang std::cout << "The type of nullvar is " << typeid(nullvar).name() << '\n'; if constexpr(std::is_same_v<decltype(NULL), std::nullptr_t>) std::cout << "NULL implemented with type std::nullptr_t\n"; else std::cout << "NULL implemented using an integral type\n"; [](...){}(p, p2, f, mp, mfp); // < suppresses "unused variable" warnings } Possible output: The type of nullvar is long NULL implemented using an integral type ·
🌐
Eskimo
eskimo.com › ~scs › cclass › notes › sx10d.html
10.4 Null Pointers
All of these uses are legal, and although I recommend that you use the constant NULL for clarity, you will come across the other forms, so you should be able to recognize them. You can use a null pointer as a placeholder to remind yourself (or, more importantly, to help your program remember) that a pointer variable does not point anywhere at the moment and that you should not use the ``contents of'' operator on it (that is, you should not try to inspect what it points to, since it doesn't point to anything).
🌐
Lysator
lysator.liu.se › c › c-faq › c-1.html
Null Pointers
The language definition states that for each pointer type, there is a special value -- the "null pointer" -- which is distinguishable from all other pointer values and which is not the address of any object or function. That is, the address-of operator & will never yield a null pointer, nor ...
🌐
IBM
ibm.com › docs › en › xl-c-aix › 13.1.2
Null pointer constants
March 5, 2021 - Indicate errors in returning a pointer from a function. A null pointer constant is an integer constant expression that evaluates to zero. For example, a null pointer constant can be 0, 0L, or such an expression that can be cast to type (void *)0.
🌐
Scaler
scaler.com › home › topics › what is null pointer in c?
What is Null Pointer in C? - Scaler Topics
September 4, 2023 - In the C programming language, ... That is, the null pointer in C holds the value Null, but the type of the pointer is void....
🌐
CodeWithHarry
codewithharry.com › tutorial › c-null-pointer
NULL Pointer | C Tutorial | CodeWithHarry
NULL pointers and void pointers very much sound similar just because of their nomenclatures, but they are very different as a NULL pointer is a pointer with a NULL value address, and a void pointer is a pointer of void data type.
🌐
Tutorialspoint
tutorialspoint.com › cplusplus › cpp_null_pointers.htm
C++ Null Pointers
The NULL pointer is a constant with a value of zero defined in several standard libraries, including iostream.
🌐
Grokipedia
grokipedia.com › null pointer
Null pointer — Grokipedia
January 14, 2026 - In C++, nullptr (introduced in the C++11 standard) is the recommended null pointer literal, which is a prvalue of type std::nullptr_t and avoids ambiguities associated with using 0 or NULL in contexts involving function overloads or template arguments.
🌐
GNU
gnu.org › software › c-intro-and-ref › manual › html_node › Null-Pointers.html
Null Pointers (GNU C Language Manual)
(The cast operator performs explicit type conversion; See Explicit Type Conversion.) You can store a null pointer in any lvalue whose data type is a pointer type: