Possible Duplicate:
What does the \0 symbol mean in a C string?
I am new at iPhone Development. I want to know, what does '\0'
means in C, and what is the equivalent for that in objective c.
Possible Duplicate:
What does the \0 symbol mean in a C string?
I am new at iPhone Development. I want to know, what does '\0'
means in C, and what is the equivalent for that in objective c.
The null character
'\0'
(alsonull terminator
), abbreviatedNUL
, is a control character with the valuezero
. Its the same in C and objective CThe character has much more significance in C and it serves as a reserved character used to signify the end of a
string
,often called a null-terminated stringThe length of a C string (an array containing the characters and terminated with a
'\0'
character) is found by searching for the (first) NUL byte.In C
\0
is a character literal constant store into anint
data type that represent the character with value of 0.Since Objective-C is a strict superset of C this constant is retained.
In C,
\0
denotes a character with value zero. The following are identical:The utility of this escape sequence is greater inside string literals, which are arrays of characters:
(Note that this array has two zero characters at the end, since string literals include a hidden, implicit terminal zero.)
To the C language,
'\0'
means exactly the same thing as the integer constant0
(same value zero, same typeint
).To someone reading the code, writing
'\0'
suggests that you're planning to use this particular zero as a character.It means '\0' is a
NULL
character in C, don't know aboutObjective-C
but its probably the same.The
'\0'
inside character literals and string literals stands for the character with the code zero. The meaning in C and in Objective C is identical.To illustrate, you can use
\0
in an array initializer to construct an array equivalent to a null-terminated string:In general, you can use
\ooo
to represent an ASCII character in octal notation, whereo
s stand for up to three octal digits.