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
June 13, 2026 - In practice, dereferencing a null pointer may result in an attempted read or write from memory that is not mapped, triggering a segmentation fault or memory access violation. This may manifest itself as a program crash, or be transformed into a software exception that can be caught by program code. There are, however, certain circumstances where this is not the case. For example...
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ c language โ€บ null-pointer-in-c
NULL Pointer in C - GeeksforGeeks
We just have to assign the NULL value. Strictly speaking, NULL expands to an implementation-defined null pointer constant which is defined in many header files such as โ€œstdio.hโ€, โ€œstddef.hโ€, โ€œstdlib.hโ€ etc.
Published: January 10, 2025
Discussions

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
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
๐ŸŒ
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 โˆ’
๐ŸŒ
Learn C++
learncpp.com โ€บ cpp-tutorial โ€บ null-pointers
12.8 โ€” Null pointers โ€“ Learn C++
August 12, 2015 - We can easily avoid dereferencing a null pointer by using a conditional to ensure a pointer is non-null before trying to dereference it: // Assume ptr is some pointer that may or may not be a null pointer if (ptr) // if ptr is not a null pointer std::cout << *ptr << '\n'; // okay to dereference else // do something else that doesn't involve dereferencing ptr (print an error message, do nothing at all, etc...)
๐ŸŒ
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:
๐ŸŒ
ScienceDirect
sciencedirect.com โ€บ topics โ€บ computer-science โ€บ null-pointer
Null Pointer - an overview | ScienceDirect Topics
In this example, calling ptr_new with the optional keyword allocate_heap creates a pointer (ptr2) that points to an undefined variable. When the pointer is dereferenced via help, the undefined variable that ptr2 points to is exposed. The pointer ptr2 can subsequently be directed to point to a defined variable: The third way is to create an invalid (null) pointer:
Find elsewhere
๐ŸŒ
EDUCBA
educba.com โ€บ home โ€บ software development โ€บ software development tutorials โ€บ c programming tutorial โ€บ null pointer in c
Null pointer in C | How Null pointer work in C with Examples
March 28, 2023 - Explanation: In the above code, we are initializing the variable โ€œptrโ€ to 0 (zero) so when we print the pointer value which Null pointer. Suppose let us take another example where the pointer variables are not assigned to any memory address.
Address: Unit no. 202, Jay Antariksh Bldg, Makwana Road, Marol, Andheri (East),, 400059, Mumbai
๐ŸŒ
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.
๐ŸŒ
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.
๐ŸŒ
Dot Net Tutorials
dotnettutorials.net โ€บ home โ€บ null pointer in c
Null Pointer in C Language with Examples - Dot Net Tutorials
November 16, 2023 - A null pointer points to the 0th memory location, a reserved memory that cannot be dereferenced. In the below example, we create a pointer *ptr and assign a NULL value to the pointer, which means that it does not point to any variable.
๐ŸŒ
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.
๐ŸŒ
W3Schools
w3schools.com โ€บ c โ€บ c_null.php
C NULL
You can compare a pointer to NULL to check if it is safe to use. Many C functions return NULL when something goes wrong. For example, fopen() returns NULL if a file cannot be opened, and malloc() returns NULL if memory allocation fails.
๐ŸŒ
IBM
ibm.com โ€บ docs โ€บ en โ€บ xl-c-aix โ€บ 13.1.0
Null pointers - IBM Documentation
March 5, 2021 - 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.
๐ŸŒ
WsCube Tech
wscubetech.com โ€บ resources โ€บ c-programming โ€บ null-pointer
Null Pointer in C Language (Uses, Best Practices, Examples)
July 27, 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.
๐ŸŒ
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.
๐ŸŒ
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.
๐ŸŒ
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.
๐ŸŒ
Lysator
lysator.liu.se โ€บ c โ€บ c-faq โ€บ c-1.html
Null Pointers
If the (char *) cast were omitted, the compiler would not know to pass a null pointer, and would pass an integer 0 instead. (Note that many Unix manuals get this example wrong.)