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.

+3


source to share


7 replies


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.

+6


source


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.)

+6


source


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 .

+5


source


\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

).

+1


source


By the C language, '\0'

means the same as an integer constant 0

(same zero value, same type int

).

For someone reading the code, the entry '\0'

suggests that you plan on using that null character as a character.

+1


source


C \0

stores a constant character letter in the datatype int

that represent the character with the value 0.

Since Objective-C is a strict superset of C, this constant is preserved.

0


source


This means that '\ 0' is a character NULL

in C, doesn't know about Objective-C

, but probably the same.

-3


source







All Articles