需要澄清 [英] Need Clarification

查看:70
本文介绍了需要澄清的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你可以告诉我更多abt如何将数组[20]转换成字符串

a ... !!


到这个问题有人回答:


不,它不会转换为字符串对象。

这里字符串的表示形式为字符数组。


好​​的。这部分没问题。


它可以分类取决于用来表示结束的字符

of字符串。 在C中它是ASCII-Z表示并以ASCII结尾

值0"


这个评论是否正确?我没有在C

标准中找到任何类似的东西,或者我错过了什么?


那些不使用ASCII字符集的系统怎么办?说如果他们使用EBCDIC而不是使用EBCDIC?)

Can u tell me more abt how did the array a[20] got converted into string
a...!!

To this question some-one answered :

No, it won''t convert into string object.
Here the representation of string is as character arrays.

Ok.This part is fine.

It can be classifieds depends on the character used to indicate the end
of the string. "In C it is ASCII-Z representation and end with ASCII
value 0"

Is this comment correct ? I did not find anything similar in the C
standard or am i missing something ?

What about systems that don''t use the ASCII character set (say if they
use EBCDIC instead ?)

推荐答案

新手说:
Newbie said:

你能告诉我更多关于阵列a [20]如何转换成字符串

a ... !!
Can u tell me more abt how did the array a[20] got converted into string
a...!!



数组不能再转换成字符串而不是蛋盒可以将b $ b转换成蛋。数组是你放入的东西。一个字符串是

你放的东西。

An array can no more be converted into a string than an egg-box can be
converted into eggs. An array is something you put things in. A string is
something you put.


它可以分类取决于所用的字符表示字符串的结尾

。 在C中它是ASCII-Z表示并以ASCII结尾

值0"


这个评论是否正确?
It can be classifieds depends on the character used to indicate the end
of the string. "In C it is ASCII-Z representation and end with ASCII
value 0"

Is this comment correct ?



C号不要求实现使用ASCII。字符串由执行字符集中代码为0的字符终止




< snip>


-

Richard Heathfield< http://www.cpax.org.uk>

电子邮件:-http:// www。 + rjh @

谷歌用户:< http://www.cpax.org.uk/prg/writings/googly.php>

Usenet是一个奇怪的放置" - dmr 1999年7月29日

No. C does not require implementations to use ASCII. Strings are terminated
by the character with code point 0 in the execution character set.

<snip>

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999


在文章< g5 ********** @ aioe.org> ;,新手< ne **** @ gmail.comwrote:
In article <g5**********@aioe.org>, Newbie <ne****@gmail.comwrote:

>你能告诉我更多关于数组a [20]如何转换成字符串
a !! !!
>Can u tell me more abt how did the array a[20] got converted into string
a...!!


>对于这个问题,有人回答:
>To this question some-one answered :


>不,它不会转换为字符串对象。
这里字符串的表示形式为字符数组。
>No, it won''t convert into string object.
Here the representation of string is as character arrays.


>好的。这部分没问题。
>Ok.This part is fine.


>它可以分类取决于用于表示字符串结束的字符。 在C中它是ASCII-Z表示并以ASCII结尾值
值0
>It can be classifieds depends on the character used to indicate the end
of the string. "In C it is ASCII-Z representation and end with ASCII
value 0"


>这个评论是否正确?我没有在C
标准中找到任何类似的东西,或者我错过了什么?
>Is this comment correct ? I did not find anything similar in the C
standard or am i missing something ?


>那些不使用ASCII字符集的系统怎么样(比如说他们是否使用EBCDIC?)
>What about systems that don''t use the ASCII character set (say if they
use EBCDIC instead ?)



无论你使用哪个字符集,C字符串都存储在
C数组的char中,字符串可能小于数组它存储在
中。字符串的结尾(与

字符数组的结尾相对)是第一个数值为0的数组条目;如果那个

数字0碰巧恰好在数组的开头,那么

字符串通常被称为空字符串。 - 但请注意

和空 string实际上需要有一个值存储在其中,

数字0表示字符串的结尾。


-

"我将推测[...]应用程序实际上可以通过双核[...]实现大多数用户的性能提升,因为它... />
正在运行广告软件和间谍软件,否则将降低用户今天使用的单个CPU的价格。 - Herb Sutter

No matter which character set you are using, C strings are stored in
C array of char, and the string may be smaller than the array that it
is stored in. The end of the string (as opposed to the end of the
char array) is the first array entry with numeric value 0; if that
numeric 0 happens to be right at the beginning of the array, then the
string is commonly referred to as being "empty" -- but note that
an "empty" string actually needs to have one value stored in it, the
numeric 0 that marks the end of the string.

--
"I will speculate that [...] applications [...] could actually see a
performance boost for most users by going dual-core [...] because it
is running the adware and spyware that [...] are otherwise slowing
down the single CPU that user has today" -- Herb Sutter


Newbie< ne **** @ gmail.comwrites:
Newbie <ne****@gmail.comwrites:

你能来吗告诉我更多abt如何将数组[20]转换成

string a ... !!


对于这个问题,有人回答:


不,它不会转换为字符串对象。

这里字符串的表示形式为字符数组。


好​​的。这部分没问题。


它可以分类取决于用于表示字符串结尾的字符的字符。 在C中它是ASCII-Z表示并以
结束
ASCII值0"


这个评论是否正确?我没有在C

标准中找到任何类似的东西,或者我错过了什么?


那些不使用ASCII字符集的系统怎么办?如果他们使用EBCDIC而不是
?)
Can u tell me more abt how did the array a[20] got converted into
string a...!!

To this question some-one answered :

No, it won''t convert into string object.
Here the representation of string is as character arrays.

Ok.This part is fine.

It can be classifieds depends on the character used to indicate the
end of the string. "In C it is ASCII-Z representation and end with
ASCII value 0"

Is this comment correct ? I did not find anything similar in the C
standard or am i missing something ?

What about systems that don''t use the ASCII character set (say if they
use EBCDIC instead ?)



这似乎是谈话的中间但我没有背景

就这样我所能说的就是:


如果一个字符数组有一个零字节就可以说是一个C字符串

在它的某个地方。所有C字符串都是零终止。没有零字节的字符

数组只是一个字符数组。

字符集并不重要 - 只有标记

结尾的字节才算数为零。所有理智的字符集确保零

可以用于此目的。


实际上,一个数组可以容纳多个字符串,但究竟有多少

是一个定义问题。这个数组:


char my_strings [] = {''a'',''b'',''c'',''\'',''d '',''\ 0''};


中至少有两个字符串:C表达式my_strings和

my_strings + 4都指向到有效字符串的开头(有些人

选择说my_strings *是*一个字符串 - 随意在

随意对话中这样做,但从技术上说它是指向

字符串开头的指针。


my_strings + 1,my_strings + 2等等也指向(开头)

字符串,这样可以说数组可以容纳5个字符串,这些字符串将比较不同。它有两个零长度字符串

(my_strings + 3和my_strings + 5)但它们相等。


希望有帮助。


-

Ben。

This seems to be the middle of a conversation but I have no context
for it so all I can say is:

A character array can be said to hold a C string if it has a zero byte
somewhere in it. All C strings are zero terminated. A character
array without a zero byte is just an array of characters. The
character set is not important -- only that the byte that marks the
end be arithmetically zero. All sane character sets ensure that zero
can be used for this purpose.

In fact, an array can hold more than one string, but exactly how many
is a matter of definition. This array:

char my_strings[] = { ''a'', ''b'', ''c'', ''\0'', ''d'', ''\0'' };

has at least two strings in it: the C expressions my_strings and
my_strings + 4 both point to the start of valid strings (some people
choose to say that my_strings *is* a string -- feel free to do that in
casual conversation, but technically it is a pointer to the start of a
string).

my_strings + 1, my_strings + 2, and so on also point to (the start of)
strings, so that array can be said to hold 5 strings that would
compare as being different. It has two zero length strings
(my_strings + 3 and my_strings + 5) but they compare equal.

Hope that helps.

--
Ben.


这篇关于需要澄清的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆