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' (also null terminator ), abbreviated NUL , is a control character with the value zero . Its the same in C and objective C. The 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 string.
'\0' is referred to as NULL character or NULL terminator It is the character equivalent of integer 0(zero) as it refers to nothing In C language it is generally used to mark an end of a string.
'\0' is referred to as NULL character or NULL terminator It is the character equivalent of integer 0(zero) as it refers to nothing. In C language it is generally used to mark an end of a string.
\0 is just one more character from malloc and free perspective, they don't care what data you put in the memory. So free will still work whether you add \0 in the middle or don't add \0 at all. The extra space allocated will still be there, it won't be returned back to the process as soon as you add \0 to the memory.
The null character '\0'
(also null terminator
), abbreviated NUL
, is a control character with the value zero
. Its the same in C and objective C
The 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 string
The 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
denotes a character with value zero. The following are identical:
char a = 0;
char b = '\0';
The utility of this escape sequence is greater inside string literals, which are arrays of characters:
char arr[] = "abc\0def\0ghi\0";
(Note that this array has two zero characters at the end, since string literals include a hidden, implicit terminal zero.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With