We are independent & ad-supported. We may earn a commission for purchases made through our links.
Advertiser Disclosure
Our website is an independent, advertising-supported platform. We provide our content free of charge to our readers, and to keep it that way, we rely on revenue generated through advertisements and affiliate partnerships. This means that when you click on certain links on our site and make a purchase, we may earn a commission. Learn more.
How We Make Money
We sustain our operations through affiliate commissions and advertising. If you click on an affiliate link and make a purchase, we may receive a commission from the merchant at no additional cost to you. We also display advertisements on our website, which help generate revenue to support our work and keep our content free for readers. Our editorial team operates independently of our advertising and affiliate partnerships to ensure that our content remains unbiased and focused on providing you with the best information and recommendations based on thorough research and honest evaluations. To remain transparent, we’ve provided a list of our current affiliate partners here.

Our Promise to you

Founded in 2002, our company has been a trusted resource for readers seeking informative and engaging content. Our dedication to quality remains unwavering—and will never change. We follow a strict editorial policy, ensuring that our content is authored by highly qualified professionals and edited by subject matter experts. This guarantees that everything we publish is objective, accurate, and trustworthy.

Over the years, we've refined our approach to cover a wide range of topics, providing readers with reliable and practical advice to enhance their knowledge and skills. That's why millions of readers turn to us each year. Join us in celebrating the joy of learning, guided by standards you can trust.

What Is a Null Character?

By Eugene P.
Updated: May 16, 2024

A null character in computer programming is a character with the value of zero. It is different from the numeral zero, which is part of the standard printed character set. Null is actually a control character with the index of zero. It is used to indicate that a variable, class or pointer is empty, undefined or not initialized. A null also is used in the C programming language to mark the end of a string of characters.

The null character originally was one of a series of special control characters used to communicate with peripheral hardware such as printers or tape drives. The original meaning of null was to instruct a device to do nothing. As technology became more sophisticated, control characters were needed less for interfacing with external devices. The null remained in most character sets, however, at position zero.

Many programming languages use the null character to indicate that a value has not been assigned to a variable, pointer or class. The value of null is often defined within the programming language’s core libraries as the value '/0', which translates into a single blank character. A variable with the value null does not have the value of zero. Zero is a completely different character code, so tests of equivalency between zero and null will show a result of false. This is by design, because zero can be a valid value for a variable.

The programming language known as C uses the null character to great effect to save memory space. The null character is used as the end of a string of characters, also called a null terminated string. This allows the program to store a string with the need for only one extra byte to hold the null terminator. The null character could not be displayed and was not used for any other purpose, so this system worked well.

Languages that came after C started to use null to initialize new variables and classes. Most language specifications actually guarantee that newly declared variables will equal null. Similarly, variables can be assigned the value null to indicate that they have no value or that they do not point to any memory location.

Certain object-oriented languages can use the null character during the process of garbage collection. If a variable holding an instance of a class is set to null, the data become unreachable unless otherwise referenced by another variable. The garbage collection mechanism, which frees memory that was previously being used, detects the now-unreachable data and returns it to the available memory pool. Explicitly assigning a variable to null is sometimes considered a poor programming style.

EasyTechJunkie is dedicated to providing accurate and trustworthy information. We carefully select reputable sources and employ a rigorous fact-checking process to maintain the highest standards. To learn more about our commitment to accuracy, read our editorial process.
Discussion Comments
EasyTechJunkie, in your inbox

Our latest articles, guides, and more, delivered daily.

EasyTechJunkie, in your inbox

Our latest articles, guides, and more, delivered daily.