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 weeks ago - There are occasions when dereferencing a pointer to address zero is intentional and well-defined; for example, BIOS code written in C for 16-bit real-mode x86 devices may write the interrupt descriptor table (IDT) at physical address 0 of the machine by dereferencing a pointer with the same value as a null pointer for writing.
🌐
GeeksforGeeks
geeksforgeeks.org β€Ί c language β€Ί null-pointer-in-c
NULL Pointer in C - GeeksforGeeks
By specifically mentioning the NULL pointer, the C standard gives a mechanism using which a C programmer can check whether a given pointer is legitimate or not. The malloc() function returns the NULL pointer when the memory allocation is failed.
Published Β  January 10, 2025
Discussions

Checking for null pointers when 0 is a valid address
C does not require the bit pattern of the null pointer to be 0, and there is at least one compiler that will let you change it. TenDRA's -f translator option makes it 0x55555555. Here's a Godbolt example. In practice, this will give you trouble because your code or a library you use likely ... 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
Understanding difference between 0 and NULL
NULL is a macro that expands to a null pointer constant. 0 is a null pointer constant. That means NULL could just be defined as 0. Put simply, sizeof (NULL) is simply not something you can rely on as having a consistent, implementation-independent meaning β€” you don't even know what type NULL has. It is entirely possible for sizeof (NULL) to be not equal to sizeof (void *). If you want to know how big a particular pointer type is, use sizeof on that pointer type, or on a value of that pointer type. More on reddit.com
🌐 r/C_Programming
36
15
July 2, 2023
You're dereferencing a null pointer!
Dereferencing a null pointer does indeed deserve a whack to the back of the head. More on reddit.com
🌐 r/videos
229
4886
July 1, 2017
People also ask

What is a null pointer in C?
A null pointer in C is a pointer that does not point to any valid memory location and is assigned the value NULL.
🌐
wscubetech.com
wscubetech.com β€Ί resources β€Ί c-programming β€Ί null-pointer
Null Pointer in C Language (Uses, Best Practices, Examples)
What is the value of a null pointer in C?
The value is NULL, which is usually defined as ((void *)0) or 0, depending on the system.
🌐
wscubetech.com
wscubetech.com β€Ί resources β€Ί c-programming β€Ί null-pointer
Null Pointer in C Language (Uses, Best Practices, Examples)
Can null pointers be assigned to multiple pointer types?
Yes, NULL can be assigned to any pointer regardless of type.
🌐
wscubetech.com
wscubetech.com β€Ί resources β€Ί c-programming β€Ί null-pointer
Null Pointer in C Language (Uses, Best Practices, Examples)
🌐
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!

🌐
TutorialsPoint
tutorialspoint.com β€Ί cprogramming β€Ί c_null_pointer.htm
NULL Pointer in C
Checking if the FILE pointer returned by the fopen() function is NULL is always a recommended approach to avoid runtime errors in file-related processing. The following example shows how you can use the NULL file pointer to ensure that a file is accessible or not βˆ’
🌐
Scaler
scaler.com β€Ί home β€Ί topics β€Ί what is null pointer in c?
What is Null Pointer in C? - Scaler Topics
September 4, 2023 - A null pointer refers to the 0th memory location, which is a shared memory area that can't be dereferenced. In the example below, We create a pointer *ptr and assign it the value NULL to indicate that it doesn't point to any variables.
🌐
WsCube Tech
wscubetech.com β€Ί resources β€Ί c-programming β€Ί null-pointer
Null Pointer in C Language (Uses, Best Practices, Examples)
March 18, 2026 - Learn in this tutorial about the null pointer in C, including its syntax, uses, how to check it, best practices, and examples to write efficient programs.
Find elsewhere
🌐
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 - The incorrectUse() function directly dereferences the pointer without checking if it's NULL. This results in undefined behavior because we're attempting to access memory that doesn't exist. This example shows why it is important to check if the NULL pointer was successfully created in dynamic memory allocation.
🌐
Javatpoint
javatpoint.com β€Ί null-pointer-in-c
Null Pointer in C - javatpoint
Null Pointer in C with programming examples for beginners and professionals covering concepts, control statements, c array, c pointers, c structures, c union, c strings and more.
🌐
ScienceDirect
sciencedirect.com β€Ί topics β€Ί computer-science β€Ί null-pointer
Null Pointer - an overview | ScienceDirect Topics
Dereferencing a null pointer can lead to unexpected and severe behavior, including kernel crashes. A classic example involves a kernel module where dereferencing a null pointer caused a panic and a crash report indicating a null pointer bug in the init_module function.
🌐
Codecademy
codecademy.com β€Ί docs β€Ί pointers β€Ί null pointer
C | Pointers | Null Pointer | Codecademy
February 3, 2025 - #include <stddef.h> pointer_type *pointer_name = NULL; ... In the example, we declare an integer pointer ptr and initialize it to NULL, indicating that it doesn’t point to any valid memory location:
🌐
Tutorialspoint
tutorialspoint.com β€Ί cplusplus β€Ί cpp_null_pointers.htm
C++ Null Pointers
#include <iostream> using namespace std; int main () { int *ptr = NULL; cout << "The value of ptr is " << ptr ; return 0; } When the above code is compiled and executed, it produces the following result βˆ’ ... On most of the operating systems, programs are not permitted to access memory at address 0 because that memory is reserved by the operating system. However, the memory address 0 has special significance; it signals that the pointer is not intended to point to an accessible memory location.
🌐
GNU
gnu.org β€Ί software β€Ί c-intro-and-ref β€Ί manual β€Ί html_node β€Ί Null-Pointers.html
Null Pointers (GNU C Language Manual)
A pointer value can be null, which means it does not point to any object. The cleanest way to get a null pointer is by writing NULL, a standard macro defined in stddef.h. You can also do it by casting 0 to the desired pointer type, as in (char *) 0.
🌐
IncludeHelp
includehelp.com β€Ί c-programs β€Ί an-example-of-null-pointer-in-c.aspx
An Example of Null pointer in C
March 10, 2024 - ptr1 is initialized with the address of the integer variable num, thus ptr1 contains a valid memory address. ptr2 is uninitialized and ptr3 assigned 0. Thus, ptr2 and ptr3 are the NULL pointers.
🌐
Electro4u
electro4u.net β€Ί blog β€Ί what-is-a-null-pointer-55
Understanding Null Pointers: Definition, Examples, and Solutions
Error handling: In some cases, a function may return a null pointer to indicate that an error occurred during its execution. For example, if a function that allocates memory fails to allocate the requested amount of memory, it may return a null pointer to indicate the failure.
🌐
CodeWithHarry
codewithharry.com β€Ί tutorial β€Ί c-null-pointer
NULL Pointer | C Tutorial | CodeWithHarry
The dereferencing behavior of a NULL pointer is very much similar to that of a void pointer. A NULL pointer itself is a kind of a VOID pointer and hence, we have to typecast it into any data type the way we do to a void pointer before dereferencing.
🌐
Sanfoundry
sanfoundry.com β€Ί c-tutorials-null-pointer
NULL Pointer in C Programming with Examples - Sanfoundry
December 31, 2025 - Dereferencing NULL Pointers: Attempting to access the value pointed to by a NULL pointer leads to segmentation faults. ... Assuming Non-NULL Without Checks: Never assume a pointer is valid without checking for NULL, especially when dealing with dynamic memory or external function returns.
🌐
IBM
ibm.com β€Ί docs β€Ί en β€Ί i β€Ί 7.5.0
Null pointers - IBM Documentation
September 29, 2025 - 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.
🌐
Grokipedia
grokipedia.com β€Ί null pointer
Null pointer β€” Grokipedia
January 14, 2026 - Consider an example in x86 assembly, where dereferencing a null pointer might compile to an instruction like mov eax, [0], which loads the value at memory address 0 into the EAX register.
🌐
Lenovo
lenovo.com β€Ί home
Null Pointer in Programming – Definition, Uses, and Common Pitfalls | Lenovo US
Yes, null pointers are widely used in conditional statements to test whether a pointer is valid or not. For example, by checking if a pointer is null, developers ensure safe logic execution.