A null character is programming code representing a character with no value, a missing value, or used to denote the end of a character string. In databases and spreadsheets, a null character can also be used as padding. An example of a null character is when a software developer declares a variable without specifying a value, or sets it equal to nothing.

Null character examples in coding

Below are examples of null characters used in the C and JavaScript programming languages.

Example code in C

#include <stdio.h> #include <string.h> int main () { char str[] = “computerhope”; printf(“As a string:\n”); printf("%s\n",str); printf(“As an array of characters (character, decimal value of character):\n”); printf("’%c’ %d\n",str[0],str[0]); printf("’%c’ %d\n",str[1],str[1]); printf("’%c’ %d\n",str[2],str[2]); printf("’%c’ %d\n",str[3],str[3]); printf("’%c’ %d\n",str[4],str[4]); printf("’%c’ %d\n",str[5],str[5]); printf("’%c’ %d\n",str[6],str[6]); printf("’%c’ %d\n",str[7],str[7]); printf("’%c’ %d\n",str[8],str[8]); printf("’%c’ %d\n",str[9],str[9]); printf("’%c’ %d\n",str[10],str[10]); printf("’%c’ %d\n",str[11],str[11]); printf("’%c’ %d\n",str[12],str[12]); return 0; }

Example output from C

Example code in JavaScript

Null Character Example

Null Character Example

Example output from JavaScript

Blank, Empty, Nbsp, Non-printing character, Null, Null pointer, Programming terms, Undefined