cannot convert from ✀const int✀ to ✀int [3][4]✀

2024-10-30 10:20:48
推荐回答(3个)
回答1:

cannot convert from 'const int' to 'int [3][4]'意思是不能转换的const int到int [ 3 ] [ 4 ]”

双语例句
1、索取资源力求简单,利用资源转换完全。
1, to obtain resources and strive to be simple, the use of resource conversion completely.
2、人生要灵活。未来时代的工作者们可能必须要经常转换职业角色。
2, life should be flexible. The workers in the future may have to change their roles in the future.
3、那些已经在上个季节盛开的花儿,早已经被季节的转换埋藏了起来。我的生活依然一如既往的平静,只是多了些眼中的疲惫。
3, those who have been in the last season of flowers, has been the conversion of the season has been buried. My life is still, as always, calm, just a little more tired.
4、正确的角色定位需要理智,及时的角色转换需要智慧。
4, the correct role of the role of the need to reason, the role of timely conversion needs wisdom.

回答2:

改成: int a[]={2,3,4}就可以了.
因为定义的是指针而赋值的是整型数组.
可以定义指针来指向整型数组,但是不能用整型数组来初始化一个整型指针.
可以这样用:
int a[]={3,4,5};
int *pInt = a;
for( int i = 0 ; i < 3 ; i++)
{
printf("%d",*pInt);
pInt++;
}

回答3:

>error C2440: 'initializing' : cannot convert from 'const int' to 'int []'怎么修改啊?
int a[]=(1,5,4,3,2);
等号右边的括号应该用花括号:
int a[]={1,5,4,3,2};
用花括号括起来的才被看成一组数, 圆括号括起来的一组数只相当于最后一个数, 就是说, 你的写法相当于 int a[]=2, 把一个数初始化给一个数组, 就出现所述错误信息.