What does \ 0 mean?
Possible duplicate:
What does the \ 0 character in string C mean?
I am new to iPhone Development. I want to know what does it mean '\0'
in C and what is the equivalent to it in object c.
source to share
Internal character literals and string literals '\0'
denote a null code character. The meaning in C and Objective C is identical.
To illustrate, you can use \0
in an array initializer to construct an array equivalent to a null terminated string:
char str1[] = "Hello";
char str2[] = {'H', 'e', 'l', 'l', 'o', '\0'};
In general, you can use \ooo
to represent an ASCII character in octal notation, where o
is up to three octal digits.
source to share
In C, \0
denotes a character with a value of 0. The following values ββare identical:
char a = 0;
char b = '\0';
The utility of this escape sequence is more inside string literals, which are arrays of characters:
char arr[] = "abc\0def\0ghi\0";
(Note that this array has two null characters at the end, since string literals include a hidden, implicit trailing zero.)
source to share
The null character '\0'
(also null terminator
) abbreviated NUL
is a control character with a value zero
. Its the same in C and object C
The character has much more meaning in C, and it serves as a reserved character used to mark the end string
, often referred to as a null terminated string
The length of the C string (an array containing characters and terminated by a character '\0'
) is found by searching for the (first) NUL byte .
source to share
\0
- null character. It C
is mainly used to mark the end of a character string. Of course, this is a common character and can be used as such, but this is rarely the case.
Simpler versions of built-in functions to manipulate string C
require that your line has been completed with the zero point (or end at \0
).
source to share