๐ŸŒ
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
๐ŸŒ
TutorialsPoint
tutorialspoint.com โ€บ cprogramming โ€บ c_null_pointer.htm
NULL Pointer in C
The NULL constant is defined in the header files stdio.h, stddef.h as well as stdlib.h. A pointer is initialized to NULL to avoid the unpredicted behavior of a program or to prevent segmentation fault errors.
Discussions

what is a null pointer in c - Stack Overflow
I tried looking online but I didn't know exactly what to type. The Google search results I got for 'NULL pointer' were different from what I expected. ... There is also a typo in n2.next = &n2;, meaning that we will never reach n3. I would just throw this bad example away and study some other code. More on stackoverflow.com
๐ŸŒ stackoverflow.com
Why do we use Null pointers?
The value where a null pointer is pointing is irrelevant. A null pointer is a pointer that is pointing nowhere--there is no value. In C, the number 0 was defined as the representation of the null pointer. They could have picked any number, but it would have been painful. More on reddit.com
๐ŸŒ r/C_Programming
56
0
August 30, 2024
C and null pointers

C compilers don't do this analysis built-in because

  • they don't need to; the C spec doesn't expect compilers to catch U.B. at compile time

  • beyond trivial examples like this, it's hard to be completely certain that it actually 100% will be undefined behavior -- for example, this code is perfectly valid as long as it is never reached (the branch that contains it never runs, or the function that contains it isn't called)

    • lots of programs generate C code as output, and they might contain "bad" code like this but be fine because the generation ensures it's never actually reached

    • there's also the small possibility that for the particular system you're targeting, this has defined behavior (such as invoking some particular hardware trap); so it can't always be a compile error

  • it's hard to make it work beyond trivial examples like this

  • and as a result would almost never flag anything in real code written by experience C programmers

Experienced C programmers do make mistakes with undefined behavior, but usually not in such an obviously and automatically recognizable case as this. There certainly is a lot of research into detecting potential bugs in C code at compile time, but it's generally too slow to run as a part of normal compilation.

More on reddit.com
๐ŸŒ r/learnprogramming
4
1
December 6, 2020
Difference between NUL(for string) vs NULL(for pointer) in c++
The standard library doesn't define NUL, but you will most likely find that NUL and standard NULL are defined as effectively the same. Unless you're talking about the ASCII NUL character, which in C++ is '\0'. I.e. the null value of type char. For nullpointers prefer to use nullptr. NULL can be defined as literal 0, but nullptr is guaranteed not an integer. Which in some situations can matter. More on reddit.com
๐ŸŒ r/cpp_questions
17
0
September 16, 2024
๐ŸŒ
Codecademy
codecademy.com โ€บ docs โ€บ pointers โ€บ null pointer
C | Pointers | Null Pointer | Codecademy
February 3, 2025 - A NULL pointer in C is a pointer that does not point to any valid 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.
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
3 weeks ago - Programs routinely use null pointers to represent conditions such as the end of a list of unknown length or the failure to perform some action; this use of null pointers can be compared to nullable types and to the Nothing value in an option type.
๐ŸŒ
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 - A null pointer in C does not point to any memory location. They are used in dynamic memory allocation, error handling, initialization of other pointers and more.
๐ŸŒ
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. We can check for this using an if statement, and print an error message if something goes wrong. In this example, we try to open a file that does not exist.
Find elsewhere
๐ŸŒ
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, a null pointer is a pointer that does not point to any memory location and hence does not hold the address of any variables. It just stores the segment's base address. That is, the null pointer in C holds the value Null, but the type of the pointer is void.
๐ŸŒ
Flavio Copes
flaviocopes.com โ€บ home โ€บ null in c: what it is, how to check for it, and c23 nullptr
NULL in C: what it is, how to check for it, and C23 nullptr
February 13, 2020 - See how to check a pointer against it, avoid the segfault, and when to use C23's nullptr. In C, NULL is a macro that represents a null pointer: a pointer that points to nothing.
๐ŸŒ
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 - In C programming language pointers are used to point to the memory that is allocated dynamically or at run time and a pointer can be of any data type like int, float, char, etc. In this article, we are discussing the null pointer in C, where NULL is constant with value 0 in C.
Address: Unit no. 202, Jay Antariksh Bldg, Makwana Road, Marol, Andheri (East),, 400059, Mumbai
๐ŸŒ
Dot Net Tutorials
dotnettutorials.net โ€บ home โ€บ null pointer in c
Null Pointer in C Language with Examples - Dot Net Tutorials
November 16, 2023 - In C programming, a null pointer is a pointer that does not point to any valid memory location. Itโ€™s a special type of pointer used to indicate that it is not intended to point to an accessible memory location.
๐ŸŒ
Uncodemy
uncodemy.com โ€บ blog โ€บ null-pointer-in-c-and-c-plus-plus-meaning-and-usage
Null Pointer in C and C++: Meaning and Usage
So, instead of holding an actual value like an integer or a character, it holds the location in memory where the value is stored. Now, a null pointer is a special type of pointer that doesnโ€™t point to any memory location.
๐ŸŒ
Aticleworld
aticleworld.com โ€บ home โ€บ what is a null pointer in c/c++?
What is a Null Pointer in C/C++? - Aticleworld
January 25, 2023 - What is Null Pointer in C? Integer constant expression with value 0, or such an expression cast to type void *, is called a null pointer constant.
๐ŸŒ
Lysator
lysator.liu.se โ€บ c โ€บ c-faq โ€บ c-1.html
Null Pointers
A null pointer is conceptually different from an uninitialized pointer. A null pointer is known not to point to any object; an uninitialized pointer might point anywhere. See also questions 3.1, 3.13, and 17.1. As mentioned in the definition above, there is a null pointer for each pointer type, and the internal values of null pointers for different types may be different.
๐ŸŒ
Nerdsdostuff
nerdsdostuff.com โ€บ c_programming โ€บ null-pointer-in-c
Null Pointer in C - Nerds Do Stuff
May 31, 2026 - Here, ptr does not point to any valid integer variable. It is deliberately initialized to the null state. to indicate that a pointer currently points to nothing
๐ŸŒ
Sanfoundry
sanfoundry.com โ€บ c-tutorials-null-pointer
NULL Pointer in C Programming with Examples - Sanfoundry
December 31, 2025 - A NULL pointer is a pointer that does not point to any valid memory location. In C, the macro NULL is defined in several standard header files, such as stdio.h, stddef.h, and stdlib.h, and is typically set to ((void*)0) or 0.
๐ŸŒ
Coddy.Tech
coddy.tech โ€บ docs โ€บ null pointers
Runnable C Docs: NULL Pointers | Coddy
September 18, 2026 - When it has no object to point at yet - before it is assigned, after the thing it pointed at is freed, or when a function has nothing to return - it needs a value that unmistakably means "nothing here".
๐ŸŒ
Eskimo
eskimo.com โ€บ ~scs โ€บ cclass โ€บ notes โ€บ sx10d.html
10.4 Null Pointers
What this means is that no other valid pointer, to any other variable or array cell or anything else, will ever compare equal to a null pointer. The most straightforward way to ``get'' a null pointer in your program is by using the predefined constant NULL, which is defined for you by several standard header files, including <stdio.h>, <stdlib.h>, and <string.h>. To initialize a pointer to a null pointer, you might use code like