a value indicating that a pointer does not refer to a valid object
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
Checking for null pointers when 0 is a valid address
Don't use MCUs designed by crazy people. More on reddit.com
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
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
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
04:06
What is a C++ null pointer? โ - YouTube
08:29
C++ Null Pointers - YouTube
18:59
NULL Pointer | C Programming Tutorial - YouTube
04:52
NULL Pointer in C with example | what is null pointer? | Learn ...
Understanding the Null Pointers - YouTube
What is Wild Pointer and Null Pointer with Examples | Types of ...
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!
Top answer 1 of 5
4
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.
2 of 5
3
NULL is better thought of as a value of "nothing" rather than a value of zero. Using numbers is a good way to explain it, though. Say you want to accept an integer. Well most languages default new integers at 0. But then say you want 0 to mean something different than the person not supplying a number at all (e.g. undefined or null). Then you could accept a pointer to an integer instead. That pointer could be to an actual number (e.g. 0 or 1), but also to NULL to mean "nothing" (or undefined, or give me the default behavior, or whatever the program defines it as).
What is the difference between NULL and nullptr when using them for something like a Binary Search Tree? Are those interchangeable? Jun 29, 2021
r/cpp_questions 5y ago
[C++] Why can a pointer set an object to null but a reference cannot? Jan 26, 2016
r/learnprogramming 10y ago
Why can't I pass a NULL pointer through a function pointer parameter? Feb 26, 2021
r/cprogramming 5y ago
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:
Call: +917738666252
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.
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.
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.)