nullptr is a keyword denoting universal null pointer value suitable for implicit convetion to any pointer type. NULL is a macro that is implementation defined and as with many macros, its text replacement may not correctly be interpreted, especially in templates. NULL may also fall into unwanted implicit convertions. Answer from Xeverous on reddit.com
🌐
Embedded Artistry
embeddedartistry.com › home › blog › migrating from c to c++: null vs nullptr
Migrating from C to C++: NULL vs nullptr - Embedded Artistry
December 15, 2021 - Since C++11, NULL can be either an integer literal with value zero, or a prvalue of type std::nullptr_t. Because of this ambiguity, I recommend switching exclusively to nullptr.
🌐
Reddit
reddit.com › r/cpp_questions › what is the difference between null and nullptr in cpp ??
r/cpp_questions on Reddit: What is the difference between NULL and nullptr in cpp ??
March 20, 2021 - For example, it is valid to assign an integer to NULL - despite not being a pointer. Alternatively, NULL will be an integer type in templates whereas nullptr will be a unique type (std::nullptr_t) - which can also be overloaded on (e.g.
Discussions

Is C NULL equal to C++11 nullptr - Stack Overflow
I like to use nullptr instead of NULL. Now I call a C function (from libjansson in this case). NULL in C is implementation defined. For nullptr I found that "A null pointer constant is an integral More on stackoverflow.com
🌐 stackoverflow.com
NULL Define in c & c++ differs?! | Handmade Network
Your example doesn't really apply to the case of void pointers, since we cannot do pointer arithmetic with void pointers. The discussion is about the concept of null pointers and the value of 0, not necessarily the type of the integer constant 0. I don't see how 0, nullptr, NULL or ((void*)0) ... More on hero.handmade.network
🌐 hero.handmade.network
June 16, 2016
What is the difference between NULL and nullptr in cpp ??
nullptr is a keyword denoting universal null pointer value suitable for implicit convetion to any pointer type. NULL is a macro that is implementation defined and as with many macros, its text replacement may not correctly be interpreted, especially in templates. NULL may also fall into unwanted implicit convertions. More on reddit.com
🌐 r/cpp_questions
18
5
March 20, 2021
[C23] The addition of nullptr and nullptr_t is bad
I think people need to consider that changing the semantics/representation of NULL is not something the committee would do lightly, as it’s breaking, so that’s simply not an option. Jens’ proposal, in my mind, was to satisfy a semantic construction that the language did not support in any form: generic selection on the type of a nullptr in a way that provides consistent, portable safety. It’s unfortunate that this complicates the language, IMO if NULL had a fixed representation when it was conceived, this wouldn’t exist… but here we are More on reddit.com
🌐 r/C_Programming
26
21
October 1, 2023
🌐
Sololearn
sololearn.com › en › Discuss › 3097671 › null-vs-nullptr
NULL vs nullptr | Sololearn: Learn to code for FREE!
The difference is that NULL is an integer, nullptr is a pointer type. It is a crucial difference when dealing with (resolving) method overloads. They are not interchangeable*). When you talk pointer, always use nullptr.
Top answer
1 of 1
109

In C++11 and beyond, a pointer that is ==NULL will also ==nullptr and vice versa.

Uses of NULL other than comparing with a pointer (like using it to represent the nul byte at the end of a string) won't work with nullptr.

In some cases, NULL is #define NULL 0, as the integer constant 0 is special-cased in C and C++ when you compare it with pointers. This non-type type information causes some problems in both C and C++, so in C++ they decided to create a special type and value that does the same thing in the "proper" use cases, and reliably fails to compile in most of the "improper" use cases.

Insofar as your C++ implementation is compatible with the C implementation you are interoping with (very rare for this not to be true), everything should work.


To be very clear, if ptr is any kind of pointer, then the following expressions are equivalent in C++:

ptr == nullptr
ptr == NULL
ptr == 0
!ptr

As are the following:

Copyptr = nullptr
ptr = NULL
ptr = 0

and if X is some type, so are the following statements:

CopyX* ptr = nullptr;
X* ptr = NULL;
X* ptr = 0;

nullptr differs when you pass it to a template function that deduces type (NULL or 0 become an int unless passed to an argument expecting a pointer, while nullptr remains a nullptr_t), and when used in some contexts where nullptr won't compile (like char c = NULL;) (note, not char* c=NULL;)

Finally, literally:

CopyNULL == nullptr

is true.

The NULL constant gets promoted to a pointer type, and as a pointer it is a null pointer, which then compares equal to nullptr.


Despite all this, it isn't always true that:

Copy foo(NULL)

and

Copy foo(nullptr)

do the same thing.

Copyvoid bar(int) { std::cout << "int\n"; }
void bar(void*) { std::cout << "void*\n"; }
template<class T>
void foo(T t) { bar(t); }
foo(NULL);
foo(nullptr);

this prints int for NULL and void* for nullptr.

🌐
GeeksforGeeks
geeksforgeeks.org › c++ › understanding-nullptr-c
Understanding nullptr in C++ - GeeksforGeeks
Unlike NULL, nullptr cannot be assigned to integer types.
Published   4 days ago
🌐
Medium
medium.com › @pauljlucas › nullptr-in-c23-571782008dad
nullptr in C23. The new nullptr keyword in C23. | by Paul J. Lucas | Medium
July 8, 2025 - Like void* and 0, nullptr implicitly converts to any type of pointer; unlike NULL, it’s guaranteed to be a pointer.
Find elsewhere
🌐
University of Waterloo
ece.uwaterloo.ca › ~dwharder › icsrts › C › 14
NULL vs 0 vs nullptr | University of Waterloo
In the C++-11 standard, they introduced a new representation of a null pointer, namely nullptr which is of type nullptr_t.
🌐
Cplusplus
cplusplus.github.io › LWG › issue1314
Issue 1314: NULL and nullptr
Currently, the 17.2 [support.types]/3 allows NULL to be any null pointer constant. The footnote marks that 0 or 0L might be appropriate. However, this definition also allows the implementation to define NULL to be nullptr.
🌐
Microsoft
devblogs.microsoft.com › dev blogs › the old new thing › when msdn says null, is it okay to use nullptr?
When MSDN says NULL, is it okay to use nullptr? - The Old New Thing
March 13, 2019 - If NULL is defined as (void*)0 in C or as nullptr in C++, then it can be assigned only to a pointer type. And since MSDN cannot control how the C and C++ header files define NULL, it needs to work with any definition that is permitted by the ...
🌐
Quora
quora.com › Whats-the-difference-between-NULL-and-nullptr-in-C++
What's the difference between NULL and nullptr in C++? - Quora
Answer (1 of 13): NULL is a “manifest ... because of an implicit conversion. nullptr is a keyword representing a value of self-defined type, that can convert into a pointer, but not into integers....
🌐
Cppreference
en.cppreference.com › w › c › language › nullptr.html
Predefined null pointer constant (since C23) - cppreference.com
The keyword nullptr denotes a predefined null pointer constant. It is a non-lvalue of type nullptr_t.
🌐
Handmade Network
hero.handmade.network › forums › code-discussion › t › 1292-null_define_in_c__c_differs! › 2
NULL Define in c & c++ differs?! | Handmade Network
June 16, 2016 - So the C++ committee apparently decided to dictate how to implement the NULL macro by requiring that the NULL macro must be defined as 0. However if they had left it alone then the compiler writers could have created their own nullptr equivalent instead of being forced to complicate their already non-trivial type-promotion code to allow 0 constants to be promoted to pointers.
🌐
DEV Community
dev.to › pauljlucas › nullptr-in-c23-1cn6
nullptr in C23 - DEV Community
July 8, 2025 - Like void* and 0, nullptr implicitly converts to any type of pointer; unlike NULL, it’s guaranteed to be a pointer.
🌐
Pudn
pudn.club › programming › null-vs-nullptr-in-modern-c-plus-plus-what-developers-should-know
NULL vs nullptr in Modern C++: What Developers Should Know · Programmers' United Development Network
December 18, 2023 - It can convert to any pointer type. It avoids ambiguity in overload resolution. ... Unlike NULL (integer 0), nullptr has its own type: std::nullptr_t.
🌐
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 a Microsoft-specific keyword that has the same meaning as nullptr, but applies to only native code. If you use nullptr with native C/C++ code and then compile with the /clr compiler option, the compiler cannot determine ...
🌐
Reddit
reddit.com › r/c_programming › [deleted by user]
[deleted by user] : r/C_Programming
July 23, 2025 - In C, NULL is an implementation-defined value that evaluates to the null pointer constant, possibly cast to void*. nullptr is an explicit null pointer value. As long as you are comparing them to pointers (like the return of fopen), then they are interchangeable.
🌐
Medium
medium.com › @weidagang › modern-c-nullptr-fa494808d31a
Modern C++: nullptr. Saying Goodbye to NULL | by Dagang Wei | Medium
June 24, 2024 - It has its own distinct type (std::nullptr_t), ensuring type safety and eliminating the ambiguity associated with NULL and 0. int* ptr = nullptr; // Clear indication of a null pointer
🌐
Hacker News
news.ycombinator.com › item
> But does C need a nullptr keyword? Yes, it does. > If you're programming in C,... | Hacker News
May 16, 2023 - That was also the usual pattern in C++ when there was no alternative. Once nullptr was introduced in C++, NULL or 0 quickly became a code smell · C++'s type system is far from insane. It's actually one of it's killer features