字符串和字符数组...... [英] String and Character Array...

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

问题描述



我对jargons感到困惑。

当说技术上正确时说..字符串或字符数组。在c。

只是告诉我你对这个问题的看法。

提前完成。

Hi,
I am in confusion regarding jargons.
When it is technically correct to say.. String or Character Array.in c.
just give me your perspectives in this issue.
Thanx in Advance.

推荐答案

Shhnwz .a写道:
Shhnwz.a wrote:



我对jargons感到困惑。

技术上是正确的to say .. String or Character Array.in c。

只是在这个问题上给我你的观点。

提前的Thanx。
Hi,
I am in confusion regarding jargons.
When it is technically correct to say.. String or Character Array.in c.
just give me your perspectives in this issue.
Thanx in Advance.



在C中,所有字符串都是字符数组,但反过来并不总是

true。例如:

char carray [BUFSIZ];

声明一组BUFSIZ字符。

char string [] =" Hello" ;;

声明一个char类型的数组,它有六个元素。也可以将

视为字符串,只要字符串[5] ==''\'''为真。


如果你这样做string [5] =''o'',然后string变为char数组但是

不再是字符串。如果传递给期望nul终止字符串的
函数,它将调用未定义的行为。


简而言之,字符串是一个字符数组[s],由nul

字符终止。一个简单的字符数组没有这样的要求。

In C, all strings are character arrays but the reverse is not always
true. For example:
char carray[BUFSIZ];
declares an array of BUFSIZ characters.
char string[] = "Hello";
declares an array of type char having six elements. In can also be
treated as a string as long as string[5] == ''\0'' is true.

If you do string[5] = ''o'', then string becomes an array of char but is
no longer a string. It will invoke undefined behaviour if passed to
functions that expect a nul terminated string.

In short, a string is an array of character[s], terminated by a nul
character. A plain array of characters has no such requirement.


" Shhnwz.a" < ms *********** @ gmail.comwrites:
"Shhnwz.a" <ms***********@gmail.comwrites:

我对jargons感到困惑。

当说技术上正确的时候..字符串或字符数组。在c。

只是给我你在这个问题上的观点。
I am in confusion regarding jargons.
When it is technically correct to say.. String or Character Array.in c.
just give me your perspectives in this issue.



字符数组是一种类型(或该类型的对象)。例如,

" char [10]"是一种特殊的字符数组类型;给定char

obj [10];",obj是这种类型的对象。


C中的字符串不是数据类型;这是一个数据布局。正如标准

所说:


_string_是一个连续的字符序列,由

终止并包含第一个空字符。


-

Keith Thompson(The_Other_Keith) ks *** @ mib .org < http://www.ghoti.net/~kst>

圣地亚哥超级计算机中心< *< http://users.sdsc.edu/~kst> ;

我们必须做点什么。这是事情。因此,我们必须这样做。

A character array is a type (or an object of that type). For example,
"char[10]" is a particular character array type; given "char
obj[10];", "obj" is an object of that type.

A string in C is not a data type; it''s a data layout. As the standard
says:

A _string_ is a contiguous sequence of characters terminated by
and including the first null character.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.


Shhnwz.a说:
Shhnwz.a said:



我对jargons感到困惑。

当说技术上正确时..字符串或字符数组.c。
Hi,
I am in confusion regarding jargons.
When it is technically correct to say.. String or Character Array.in c.



数组是纸板箱[1]。一个字符串就是你可以放入其中的东西。

你可能会把其他东西放在那里,当然 - 或者盒子可能

只是充满了垃圾 - 但它这是为了一个字符串,就像

鸡蛋盒是为鸡蛋制作的。

[1] ...除了那个,现在,数组几乎没有纸板制成。


-

Richard Heathfield

Usenet是一个奇怪的地方 - dmr 29/7/1999
http://www.cpax.org.uk

电子邮件:rjh在上述域名中, - www。

An array is a cardboard box[1]. A string is something you might put in it.
You might put something else in there instead, of course - or the box might
just be full of junk - but it''s kind of made for a string, just like
egg-boxes are kind of made for eggs.
[1] ...except that, nowadays, arrays are hardly ever made from cardboard.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at the above domain, - www.


这篇关于字符串和字符数组......的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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