control character whose bits are all 0
The null character is a control character with the value zero. Many character sets include a code point for a null character โ€“ including Unicode (Universal Coded Character Set), ASCII (ISO/IEC 646), โ€ฆ Wikipedia
๐ŸŒ
Wikipedia
en.wikipedia.org โ€บ wiki โ€บ Null_character
Null character - Wikipedia
March 3, 2026 - The null character is a control character with the value zero. Many character sets include a code point for a null character โ€“ including Unicode (Universal Coded Character Set), ASCII (ISO/IEC 646), Baudot, ITA2 codes, the C0 control code, and EBCDIC. In modern character sets, the null character ...
Discussions

java - How do I compare a character to check if it is null? - Stack Overflow
The default value is '\u0000' i.e. 0 for a char array element. And that's exactly what you meant by empty cell, I assume. ... Save this answer. Show activity on this post. ... Save this answer. Show activity on this post. I actually came here from reading a book "Java: A Beginner's Guide" because they used this solution to compare char to null... More on stackoverflow.com
๐ŸŒ stackoverflow.com
the null character - C++ Forum
hello was stored in memory just a few bytes after world and both of them are shown as there aren't null characters between them ... Please be aware that Bazzy's example is OS- and compiler-dependant. More on cplusplus.com
๐ŸŒ cplusplus.com
February 19, 2009
NULL character in C
All ASCII characters have an associated number with it. A single space has the ASCII value of 10. The ASCII character '0' has an ASCII value of 48. The null character (which is NOT '0') has an ASCII value of 0. In particular char ch = 0; // ASCII value 0 char ch2 = '\0'; // ASCII value 0 char ch3 = '0'; // ASCII value 48 So, '0' and 0 are not the same thing. More on reddit.com
๐ŸŒ r/learnprogramming
5
0
March 7, 2023
java - What's the default value of char? - Stack Overflow
char c = '\u0000'; When I print c, it shows 'a' in the command line window. So what's the default value of a char type field? Someone said '\u0000' means null in Unicode; is that right? More on stackoverflow.com
๐ŸŒ stackoverflow.com
People also ask

What is a null character?
In programming, a null character, often denoted as '0', is a special character with all its bits set to zero. It doesn't represent a visible character like 'A' or '1', but rather serves to terminate strings in languages like C. Essentially, it shows the end of a sequence of characters. This little zero-packed warrior is more of a behind-the-scenes hero, ensuring that your programs know where the strings end.
๐ŸŒ
lenovo.com
lenovo.com โ€บ home
What is a Null Character? A Comprehensive Explanation | Lenovo US
How does the null character relate to the concept of 'null' in other programming contexts?
While the null character ('0') is specific to strings and termination in languages like C, the concept of 'null' in other programming contexts generally refers to the absence of a value or a non-existent reference. It's crucial to differentiate between the null character used for string termination and the broader concept of 'null' or 'null values'in languages like Java, JavaScript, or structured query language (SQL).
๐ŸŒ
lenovo.com
lenovo.com โ€บ home
What is a Null Character? A Comprehensive Explanation | Lenovo US
Does every programming language use the null character for string termination?
While the null character is a common choice for string termination, not all programming languages follow this convention. Some languages might use a different method, such as storing the length of the string explicitly. However, in many low-level languages like C, the null character stays a prevalent and efficient way to mark the end of a string.
๐ŸŒ
lenovo.com
lenovo.com โ€บ home
What is a Null Character? A Comprehensive Explanation | Lenovo US
๐ŸŒ
Medium
medium.com โ€บ @javacharter โ€บ can-you-check-if-char-is-null-or-not-in-java-9f5adcc51f77
Can you check if char is null or not in Java ? | by Javacharter | Medium
April 12, 2023 - If you go through the code, I have put one condition if(ch!=0) ! Yes that is true! A char in Java cannot be null as it is a primitive . If you put a null check, it will give you compile time error.
๐ŸŒ
Lenovo
lenovo.com โ€บ home
What is a Null Character? A Comprehensive Explanation | Lenovo US
February 27, 2026 - It doesn't represent a visible character like 'A' or '1', but rather serves to terminate strings in languages like C. Essentially, it shows the end of a sequence of characters. This little zero-packed warrior is more of a behind-the-scenes hero, ensuring that your programs know where the strings end. When you're working with strings in programming, the null character is like a silent sentinel.
๐ŸŒ
Cprogramming
cboard.cprogramming.com โ€บ c-programming โ€บ 112370-setting-char-*-null.html
Setting a char * to null
Just in order to maintain my image of being a nitpicker: (char *)NULL is the empty string, "\0" is a string of size 0. I think your nitpicking is incorrect: (char*)NULL is a null pointer, but "\0" is an empty string.
Find elsewhere
๐ŸŒ
OSDev Wiki
wiki.osdev.org โ€บ Null_Character
Null Character - OSDev Wiki
The null character, also known as the null terminator, is a character with the value of zero. Besides representing a NOP, nowadays it is known as the control character that indicates the end of an string in C-like data formats. In essence, the null terminator is a way to encode the end of a ...
๐ŸŒ
Cplusplus
cplusplus.com โ€บ forum โ€บ beginner โ€บ 7947
the null character - C++ Forum
February 19, 2009 - It will show only "hello" as when a null character is found the string is terminated '\0' has the same value as char( 0 )
๐ŸŒ
Computer Hope
computerhope.com โ€บ jargon โ€บ n โ€บ nullchar.htm
What Is a Null Character?
January 6, 2025 - 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.
๐ŸŒ
Wikipedia
en.wikipedia.org โ€บ wiki โ€บ Null-terminated_string
Null-terminated string - Wikipedia
March 25, 2025 - In computer programming, a null-terminated string is a character string stored as an array containing the characters and terminated with a null character (a character with an internal value of zero, called "NUL" in this article, not same as the glyph zero).
๐ŸŒ
Coderanch
coderanch.com โ€บ t โ€บ 730461 โ€บ java โ€บ null-null-character
null? null character? (Beginning Java forum at Coderanch)
May 14, 2020 - You undoubtedly recognize CR, LF, and TAB, but the character with code value 0, is known as NUL. That, however, is not a built-in Java name, no more than CR or LF are. If you want to name it, you have to do so yourself. "null", on the other hand, is a reference to no object.
๐ŸŒ
Reddit
reddit.com โ€บ r/learnprogramming โ€บ null character in c
r/learnprogramming on Reddit: NULL character in C
March 7, 2023 -

So, it's represented by '\0' or '0', right?

Why '0' too when it's value is 48 and not 0 - is it not the character '0' in ASCII but the symbol '0' used when talking about the NULL character?

EDIT: So it's just the ASCII character '\0'.

ALSO: Why is a char array printable as a string even if it contains no NULL character?

#include <stdio.h>

int main(void)
{
    char s[] = {'h', 'i', '.', '.'};
    printf("%s\n", s);
    printf("%i %i %i %i\n", s[0], s[1], s[2], s[3]);
}

prints

hi..
104 105 46 46

but if I change the last line to

printf("%i %i %i %i %i\n", s[0], s[1], s[2], s[3], s[4);

it complains "array index 4 is past the end of the array" which means there is no NULL.

EDIT: I just used the code above and changed s[] to s[5] and it printed the additional 0 - why - can't printf see the NULL if you declare the array without specifying its size in advance?

๐ŸŒ
ASCII Code
ascii-code.com โ€บ character โ€บ โ€
Null character - ASCII Code
In ASCII and Unicode, the null character is defined to be U+0000, meaning it is represented in Unicode as the number 0.
๐ŸŒ
ScienceDirect
sciencedirect.com โ€บ topics โ€บ computer-science โ€บ null-character
Null Character - an overview | ScienceDirect Topics
The null character is defined as the numerical value 0 (the ASCII null character), which is distinct from the character โ€œ0โ€ that has the ASCII code value 48. 1 In computer science, the null character is commonly represented as '\0' and is used as a string terminator in many programming ...
๐ŸŒ
Coderanch
coderanch.com โ€บ t โ€บ 656159 โ€บ java โ€บ Check-character-null
Check if character is null (Beginning Java forum at Coderanch)
October 3, 2015 - When you print out the first character in that array with the printf function the chip display the ASCII equivalent of each number, until it reaches the 00 which does not print. The 00 is called ยท the null character and that style of String is called nullโ€‘terminated Strings or zero#x2011;terminated Strings.
๐ŸŒ
Blogger
javahungry.blogspot.com โ€บ 2021 โ€บ 11 โ€บ null-character-java.html
null character java | Java Hungry
There are 3 ways through which we can represent the null or empty character in Java. 1. Using Character.MIN_VALUE 2. Using '\u0000' 3.
๐ŸŒ
DaniWeb
daniweb.com โ€บ programming โ€บ software-development โ€บ threads โ€บ 425629 โ€บ how-to-check-null-character-in-an-array
java - How to check NULL character in an array [SOLVED] | DaniWeb
June 14, 2012 - A char is a 16-bit primitive and cannot be null (only reference types can), and Java strings are not null-terminated; they store their length separately. For user input, prefer a String and use str.length() to know exactly how many UTF-16 code ...
๐ŸŒ
Sanfoundry
sanfoundry.com โ€บ c-tutorials-null-character
NULL Character in C with Examples
December 31, 2025 - C strings are arrays of characters ending with the NULL character โ€˜\0โ€˜. It tells the compiler and various standard library functions where the string ends. ... That โ€˜\0โ€˜ at the end helps functions like printf(), strlen(), strcpy() know where to stop reading the string. ... Both are valid, but the string literal version is ...