You can use c[i]= '\0' or simply c[i] = (char) 0.

The null/empty char is simply a value of zero, but can also be represented as a character with an escaped zero.

Answer from ardent on Stack Overflow
Discussions

printf - Printing chars and their ASCII-code in C - Stack Overflow
How do I print a char and its equivalent ASCII value in C? More on stackoverflow.com
๐ŸŒ stackoverflow.com
char - What is the symbol for whitespace in C? - Stack Overflow
I am trying to figure out how to check if a character is equal to white-space in C. I know that tabs are '\t' and newlines are '\n', but I want to be able to check for just a regular normal space (... More on stackoverflow.com
๐ŸŒ stackoverflow.com
How to get ASCII code of C `char` portably in ANSI C - Stack Overflow
As you all know, ANSI C does not require implementations to use ASCII code points for the char type. However it does define a basic character set with alphanumeric characters, whitespace characters... More on stackoverflow.com
๐ŸŒ stackoverflow.com
facebook - Invisible characters - ASCII - Stack Overflow
Are there any invisible characters? I have checked Google for invisible characters and ended up with many answers but I'm not sure about those. Can someone on Stack Overflow tell me more about this? More on stackoverflow.com
๐ŸŒ stackoverflow.com
๐ŸŒ
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?

๐ŸŒ
Wikipedia
en.wikipedia.org โ€บ wiki โ€บ Whitespace_character
Whitespace character - Wikipedia
2 weeks ago - Good use of white space in source code can group related logic and make the code easier to understand. Excessive use of whitespace, including at the end of a line where it provides no rendering behavior, is considered a nuisance. Most languages only recognize whitespace characters that have an ASCII code.
๐ŸŒ
Wikipedia
en.wikipedia.org โ€บ wiki โ€บ Null_character
Null character - Wikipedia
March 3, 2026 - In a string literal, the null character is often represented as the escape sequence \0 (for example, "abc\0def"). Similar notation is often used for a character literal (i.e. '\0') although that is often equivalent to the numeric literal for zero (0). In many languages (such as C, which introduced this notation), this is not a separate escape sequence, but an octal escape sequence with a single octal digit 0; as a consequence, \0 must not be followed by any of the digits 0 through 7 because in that case it will be interpreted as the start of a longer octal escape sequence.
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ c++ โ€บ g-fact-72
ASCII NULL, ASCII 0 ('0') and Numeric literal 0 - GeeksforGeeks
July 23, 2025 - The ASCII (American Standard Code for Information Interchange) NULL and zero are represented as 0x00 and 0x30 respectively. An ASCII NULL character serves as a sentinel character of strings in C/C++. When the programmer uses '0' in his code, ...
๐ŸŒ
Quora
quora.com โ€บ How-do-you-initialize-char*-to-an-empty-string-in-C
How to initialize char* to an empty string in C - Quora
An empty string in C - meaning ... simply "". It is an array of char with a element, and the value of that element is (char) 0 or '\0'; Confusingly, this character in the ASCII and UTF-8 character sets is also called NUL, ...
๐ŸŒ
Coderanch
coderanch.com โ€บ t โ€บ 572808 โ€บ java โ€บ ASCII-Empty-String
ASCII value for Empty String. (Java in General forum at Coderanch)
April 7, 2012 - No. Characters have ASCII values, not strings. And an empty string has no characters. ... Good suggestion by matthew. you can refer this website http://ascii-table.com/ for your ASCII values search. Ideally if you map it to an empty character, you would be placing a space character, which we ...
Find elsewhere
๐ŸŒ
ASCII Code
ascii-code.com โ€บ character โ€บ โ€
Null character - ASCII Code
The null character is used in C and C++ as a string terminator, marking the end of a string of characters.
๐ŸŒ
Quora
quora.com โ€บ How-do-I-check-if-a-char-array-is-empty
How to check if a char array is empty - Quora
A char array is never empty. There is something in there. It may be NULCHARs '\0' , it may characters, it may be garbage bytes. Think of a char array as what it is: data storage. In the case of char type, then the storage is a contiguous region ...
๐ŸŒ
Invisible Characters
invisible-characters.com
Unicode characters you can not see
Unicode characters you can not see -Invisible Characters
๐ŸŒ
SMU
cs.smu.ca โ€บ ~porter โ€บ csc โ€บ ref โ€บ ascii.html
Additional Reference Material | The Standard ASCII Character Set and Codes
There are several "extended" ASCII ... here. The Standard ASCII Character Set and Codes table given below contains 128 characters with corresponding numerical codes in the range 0..127 (decimal). The characters in the table fall into two main categories:...
๐ŸŒ
IceCube
user-web.icecube.wisc.edu โ€บ ~dglo โ€บ c_class โ€บ charfunc.html
C Class - Character Processing Functions
Returns a nonzero value if c is a whitespace character. In ASCII, whitespace characters are space (' '), tab ('\t'), carriage return ('\r'), newline ('\n'), vertical tab ('\v') and formfeed ('\f').
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ c language โ€บ c-ascii-value
ASCII Value of a Character in C - GeeksforGeeks
July 23, 2025 - Each ASCII code occupies 7 bits in memory. Each character variable is assigned an ASCII value ranging from 0 to 127. ... Input: char ch = 'A'; Output: ASCII value of A is 65 Explanation: The character 'A' has an ASCII value of 65. Input: char ch = 'z'; Output: ASCII value of z is 122 Explanation: The character 'z' has an ASCII value of 122. Digital computers store the information in the form of bits (0 or 1). So, to represent different characters, which can be very well over 200s, we use a sequence of bit that is stored in the memory in place of that character.
๐ŸŒ
Quora
quora.com โ€บ What-is-the-ASCII-code-for-a-blank-space
What is the ASCII code for a blank space? - Quora
Answer (1 of 2): Hello, Itโ€™s the โ€œSpaceโ€ (not white space, or blank space) in the Ascii table. In case you didnโ€™t look it through an Ascii table then please be informed the Hexadecimal code has been looked out for you, and we presently let you know this is 0x20.