两句话有什么区别? [英] what is the difference between the 2 sentences?

查看:60
本文介绍了两句话有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

全部:


第一次发送:


int main(){

char string [20] = {""};

string [20] = {"连接};

.....

}

第二句话:

int main( ){

char string [20] = {""};

string [20] ="已连接;

....

}


感谢您提出任何意见;


bin YE

Hi, all:

The 1st sendtence:

int main(){
char string[20]={""};
string[20] = {" connected "};
.....
}
The second sentence:
int main(){
char string[20]={""};
string[20]=" connected ";
....
}

Thanks for any comments;

bin YE

推荐答案

文章< 11 ************** ********@o13g2000cwo.googlegroups .com> ;,

yezi< ye ***** @ hotmail.com>写道:
In article <11**********************@o13g2000cwo.googlegroups .com>,
yezi <ye*****@hotmail.com> wrote:
第一次发送:
int main(){
char string [20] = {""};


您设置一个20个字符的数组,并在第一个

位置用\0初始化它。

string [ 20] = {"连接的};


然后尝试分配到该阵列的第21个字符。但是,您尝试分配的

值不是有效的表达式,因为表达式上下文中的{}是块分组,而不是$ / $
有一个相关的值。例如,(a,b,c)与

相关联的值是c(逗号运算符)的值不同。

....
}
第二句话:
int main(){
char string [20] = {""};


您设置一个20个字符的数组,并在第一个

位置用\0初始化它。

string [ 20] ="连接的;


然后尝试分配到该阵列的第21个字符。然而,您尝试分配的

值是指向字符的指针

string。

...
}
The 1st sendtence: int main(){
char string[20]={""};
You set up an array of 20 char and initialize it with \0 in the first
position.
string[20] = {" connected "};
You then attempt to assign into the 21st char of that array. The
value you attempt to assign is, however, not a valid expression,
because {} in an expression context is a block grouping which does not
have an associated value. Unlike, for example, (a,b,c) in which the
associated value is the value of c (the comma operator).
....
} The second sentence:
int main(){
char string[20]={""};
You set up an array of 20 char and initialize it with \0 in the first
position.
string[20]=" connected ";
You then attempt to assign into the 21st char of that array. The
value you attempt to assign is, however, a pointer to a character
string.
...
}



您可能想要探索之间的差异(如果有的话)

char string1 [20] =" connected" ;;

char string2 [20] = {" connected" };

char string3 [] =" connected";

char string4 [] = {" connected" };

-

重要的是要记住,当涉及到法律,电脑

永远不会复制,只有人类制作副本。计算机给出了

命令,而非许可。只有人才能获得许可。

- Brad Templeton


You might want to explore the differences (if any) between

char string1[20] = "connected";
char string2[20] = { "connected" };
char string3[] = "connected";
char string4[] = { "connected" };
--
"It is important to remember that when it comes to law, computers
never make copies, only human beings make copies. Computers are given
commands, not permission. Only people can be given permission."
-- Brad Templeton


yezi写道:
int main( ){
char string [20] = {""};
string [20] = {"连接"};
....
}
int main(){
char string[20]={""};
string[20] = {" connected "};
....
}






cat test.c

int main()

{

char string [20] = {""};

string [20] = {"已连接"};

返回0;

}
cat test.c
int main()
{
char string[20] = {""};
string[20] = {" connected "};
return 0;
}


这篇关于两句话有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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