为什么说char str[10]="string!"和char str[10]={"string!"};等价啊!这明明一个是字符数组一个字符串组

2024年12月03日 06:42
有3个网友回答
网友(1):

这两个是等价,不管是整体输出,或者是对某一项进行操作得到的结果是一样的!只是格式不同而已,第二种有点像二维数组初始化的感觉例如:
string sz[5][5]={ {"1","2 ","3,"4 ","5 "},
{" 1","2","3 ","4","5 " },
{" 1","2","3 ","4","5 " },
{" 1","2","3 ","4","5 " },
{" 1","2","3 ","4","5 " }}

网友(2):

从右表达式看,你的理解一点都不错;可是一个一维字符串数组与字符数组形成的串有区别吗?

网友(3):

char是字符数组,string才是字符串数组,你写的有问题吧?