What Does Null Mean in Computer Programming?

Null Is Both a Constant and a Pointer in Computer Programming

Number 0 On Wall
In C#, null is not the same as the constant zero. Przemyslaw Godzina / EyeEm/Getty Images

In computer programming, null is both a value and a pointer. Null is a built-in constant that has a value of zero. It is the same as the character 0 used to terminate strings in C. Null can also be the value of a pointer, which is the same as zero unless the CPU supports a special bit pattern for a null pointer.

What Is a Null Value?

In a database, zero is a value. The value null means that no value exists.

When used as a value, null is not a memory location. Only pointers hold memory locations. Without a null character, a string would not correctly terminate, which would cause problems.

What Is a Null Pointer?

The C and C++ programming, a pointer is a variable that holds a memory location. The null pointer is a pointer that intentionally points to nothing. If you don't have an address to assign to a pointer, you can use null. The null value avoids memory leaks and crashes in applications that contain pointers. An example of a null pointer in C is:


int main()


   int  *ptr = NULL;

   printf("The value of ptr is %u",ptr);

   return 0;


Note: In C, the null macro may have the type void* but this is not allowed in C++.

Null in C#

In C#, null means "no object." Information about null and its usages in C# include:

  • You cannot use 0 instead of null in your programs even though null is represented by the value 0.
  • You can use null with any reference type including arrays, strings, and custom types.
  • In C#, null is not the same as the constant zero.