关于字符串和字符 [英] about string and character

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

问题描述

单个字符和字符串之间有什么区别

只包含一个字符

what is the difference between a single character and a string
consisting only one character

推荐答案

文章

< bf ********************************** @ s19g2000prg。 googlegroups.com>,
da****@gmail.com < da **** @ gmail。编辑于2007年11月24日星期六2:57

pm:
In article
<bf**********************************@s19g2000prg. googlegroups.com>,
da****@gmail.com <da****@gmail.comwrote on Saturday 24 Nov 2007 2:57
pm:

单个字符和字符串之间有什么区别

只包含一个字符
what is the difference between a single character and a string
consisting only one character



尝试此程序:


#include< stdio.h>


int main(无效){

char c0 =''0'';

char c1 [] =" 0" ;


printf(" c0的大小是%u \ nSize of c1 is%u\ n,sizeof c0,sizeof c1);

返回0;

}


输出是什么?为什么''c0''和''c1'的大小不同?

你的C课本说什么?


也试试这个:


#include< stdio.h> ;


int main(无效){

printf("''''的大小是%\ n的大小为\' \\ 是%u \ n,

sizeof''a'',sizeof" a");

返回0;

}


输出是什么?为什么它们与''''和a不同??

你的教科书怎么说这个?

Try this program:

#include <stdio.h>

int main(void) {
char c0 = ''0'';
char c1[] = "0";

printf("Size of c0 is %u\nSize of c1 is %u\n", sizeof c0, sizeof c1);
return 0;
}

What is the output and why are the sizes for ''c0'' and ''c1'' different?
What does your C textbook say?

And try this one too:

#include <stdio.h>

int main(void) {
printf("Size of ''a'' is %u\nSize of \"a\" is %u\n",
sizeof ''a'', sizeof "a");
return 0;
}

What is the output and why are they different for ''a'' and "a"?
What does you textbook say about this?


在文章< fi ********** @ registered.motzarella.org>中,santosh

< sa ********* @ gmail.com写于2007年11月24日星期六下午3:28:
In article <fi**********@registered.motzarella.org>, santosh
<sa*********@gmail.comwrote on Saturday 24 Nov 2007 3:28 pm:

文章

< bf ********************************** @ s19g2000prg。 googlegroups.com>,
da****@gmail.com < da **** @ gmail。编辑于2007年11月24日星期六2:57

pm:
In article
<bf**********************************@s19g2000prg. googlegroups.com>,
da****@gmail.com <da****@gmail.comwrote on Saturday 24 Nov 2007 2:57
pm:

>单个字符和字符串之间有什么区别
仅包含一个字符
>what is the difference between a single character and a string
consisting only one character



尝试此程序:


#include< stdio.h>


int main(void){

char c0 =''0'';

char c1 [] =" 0";


printf(" c0的大小是%u \ nSize of c1 is%u\ n,sizeof c0,sizeof

c1);返回0;

}


输出是什么?为什么''c0''和''c1'的大小不同?

你的C课本说什么?


也试试这个:


#include< stdio.h>


int main(无效){

printf("''''的大小是'\'的大小'\\''a \\是%u \ n,

sizeof''a'',sizeof" a");

返回0;

}


输出是什么?为什么它们与'a'和'a'不同??

你教科书怎么说?这个?


Try this program:

#include <stdio.h>

int main(void) {
char c0 = ''0'';
char c1[] = "0";

printf("Size of c0 is %u\nSize of c1 is %u\n", sizeof c0, sizeof
c1); return 0;
}

What is the output and why are the sizes for ''c0'' and ''c1'' different?
What does your C textbook say?

And try this one too:

#include <stdio.h>

int main(void) {
printf("Size of ''a'' is %u\nSize of \"a\" is %u\n",
sizeof ''a'', sizeof "a");
return 0;
}

What is the output and why are they different for ''a'' and "a"?
What does you textbook say about this?



请注意,如果您碰巧在类型为int为两个字节的系统上编译

,则第二个示例可能会让您感到困惑。


现在仍然值得查阅你指定的教科书并做一些自己的思考,而不是在
$ b中寻求即时答案$ b新闻组。

Note that this second example could confuse you if you happen to compile
on systems where the type int is two bytes.

It''s still worthwhile to consult your prescribed textbook and do a bit
of thinking on your own rather than ask for instant answers in
newsgroups.


da****@gmail.com 写道:
da****@gmail.com wrote:

单个字符和字符串之间有什么区别

只包含一个字符
what is the difference between a single character and a string
consisting only one character



一个是单个字符,另一个是包含

a单个字符的序列,实现为指向
$ b序列的指针$ b字符,其中第二个是终止空字符,

第一个是字符串中的字符。


它就像是两者之间的区别一个苹果和一个纸袋

一个苹果:袋子不是苹果,即使你可以从中取出一个苹果

,或者用橙子代替苹果。 (由于字符串

包只能包含一个水果字符,你不能混合苹果和

橙子[1]。)


[1]在这个包里。你可以用更大的包包。


-

也许咖啡因现在? Hedgehog

引用设施包括缺乏原创思想。 /华丽之夜/

One''s a single character, and the other is a sequence containing
a single character, implemented as a pointer to a sequence of
characters the second of which is a terminating nul character and
the first is the character in the string.

It''s like the difference between an apple and a paper bag containing
an apple: the bag is not an apple, even though you can get an apple
out of it, or replace the apple with an orange. (Since the string
bag can contain only one fruit character, you can''t mix apples and
oranges [1].)

[1] In this bag. In bigger bags you can.

--
Perhaps Caffeine Now? Hedgehog
"A facility for quotation covers the absence of original thought." /Gaudy Night/


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

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