阅读背景:

\0代表什么?(复制)

来源:互联网 

Possible Duplicate:
What does the

Possible Duplicate:
What does the \0 symbol mean in a C string?

可能的重复:\0符号在C字符串中意味着什么?

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.

我是iPhone开发新手。我想知道,“\0”在C中是什么意思,在objective C中是什么意思。

7 个解决方案

#1


6  

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.

字符常量和字符串常量中的'\0'代表代码为零的字符。C和Objective C的意思是一样的。

To illustrate, you can use \0 in an array initializer to construct an array equivalent to a null-terminated string:

为了说明这一点,您可以在数组初始化器中使用\0来构造一个等价于空终止字符串的数组:

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 os stand for up to three octal digits.

通常,您可以使用\ooo来表示八进制的ASCII字符,其中os最多代表三个八进制数字。

#2


6  

In C, \0 denotes a character with value zero. The following are identical:

在C中,\0表示值为0的字符。以下是相同的:

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

(注意,这个数组末尾有两个零字符,因为字符串文字包含一个隐藏的隐式终端0。)

#3


5  

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

null字符'\0'(也是空终止符),缩写NUL,是一个值为0的控制字符。C和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

字符在C中具有更大的意义,它作为一个保留字符,用于表示字符串的结束,通常称为空终止字符串

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.

通过搜索(第一个)NUL字节,可以找到C字符串的长度(包含字符的数组,并以“\0”字符结束)。

#4


1  

\0 is zero character. In C it is mostly used to indicate the termination of a character string. Of course it is a regular character and may be used as such but this is rarely the case.

是零字符\ 0。在C语言中,它主要用于表示字符串的终止。当然,它是一个规则字符,可以这样使用,但这种情况很少发生。

The simpler versions of the built-in string manipulation functions in C require that your string is null-terminated(or ends with \0).

C中内置的字符串操作函数的简单版本要求字符串以null结尾(或者以\0结尾)。

#5


1  

To the C language, '\0' means exactly the same thing as the integer constant 0 (same value zero, same type int).

在C语言中,'\0'的意思和整型常量0完全相同(值相同,类型相同)。

To someone reading the code, writing '\0' suggests that you're planning to use this particular zero as a character.

对于正在阅读代码的人来说,写‘\0’意味着你打算使用这个特殊的‘0’作为一个字符。

#6


0  

In C \0 is a character literal constant store into an int data type that represent the character with value of 0.

在C \0中,字符文字常量存储在表示值为0的字符的int数据类型中。

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

由于Objective-C是C的严格超集,所以这个常数被保留。

#7


-2  

It means '\0' is a NULL character in C, don't know about Objective-C but its probably the same.

它的意思是'\0'在C中是空字符,不知道Objective-C,但可能是一样的。


symbol mean in a C string?What does the

Possible Duplicate:
What does the \0 symbol mean in a C string?

可能的重复:\0符号在C字符串中意味着什么?

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.

我是iPhone开发新手。我想知道,“\0”在C中是什么意思,在objective C中是什么意思。

7 个解决方案

#1


6  

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.

字符常量和字符串常量中的'\0'代表代码为零的字符。C和Objective C的意思是一样的。

To illustrate, you can use \0 in an array initializer to construct an array equivalent to a null-terminated string:

为了说明这一点,您可以在数组初始化器中使用\0来构造一个等价于空终止字符串的数组:

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 os stand for up to three octal digits.

通常,您可以使用\ooo来表示八进制的ASCII字符,其中os最多代表三个八进制数字。

#2


6  

In C, \0 denotes a character with value zero. The following are identical:

在C中,\0表示值为0的字符。以下是相同的:

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

(注意,这个数组末尾有两个零字符,因为字符串文字包含一个隐藏的隐式终端0。)

#3


5  

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

null字符'\0'(也是空终止符),缩写NUL,是一个值为0的控制字符。C和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

字符在C中具有更大的意义,它作为一个保留字符,用于表示字符串的结束,通常称为空终止字符串

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.

通过搜索(第一个)NUL字节,可以找到C字符串的长度(包含字符的数组,并以“\0”字符结束)。

#4


1  

\0 is zero character. In C it is mostly used to indicate the termination of a character string. Of course it is a regular character and may be used as such but this is rarely the case.

是零字符\ 0。在C语言中,它主要用于表示字符串的终止。当然,它是一个规则字符,可以这样使用,但这种情况很少发生。

The simpler versions of the built-in string manipulation functions in C require that your string is null-terminated(or ends with \0).

C中内置的字符串操作函数的简单版本要求字符串以null结尾(或者以\0结尾)。

#5


1  

To the C language, '\0' means exactly the same thing as the integer constant 0 (same value zero, same type int).

在C语言中,'\0'的意思和整型常量0完全相同(值相同,类型相同)。

To someone reading the code, writing '\0' suggests that you're planning to use this particular zero as a character.

对于正在阅读代码的人来说,写‘\0’意味着你打算使用这个特殊的‘0’作为一个字符。

#6


0  

In C \0 is a character literal constant store into an int data type that represent the character with value of 0.

在C \0中,字符文字常量存储在表示值为0的字符的int数据类型中。

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

由于Objective-C是C的严格超集,所以这个常数被保留。

#7


-2  

It means '\0' is a NULL character in C, don't know about Objective-C but its probably the same.

它的意思是'\0'在C中是空字符,不知道Objective-C,但可能是一样的。


symbol




你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: