为什么编译后就会出现error C2440: 'initializing' : cannot convert from 'char (*)[5]' to 'char (*)[10]'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
error C2440: 'initializing' : cannot convert from 'char [5]' to 'char (*)[10]'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
求大神指导
int main()
{
chara[5]={'A','B','C','D'};
char(*p3)[5]= &a;
return0;
}
他讲的是指针与数组的剖析的时候写的一个例子,我就是之前看到这个程序没有错误,所以把5变成10试一下结果就出现错误了
error C2440: 'initializing' : cannot convert from 'char [5]' to 'char (*)[10]'
就是说下标出错
~
不是需要强制转换吗。Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast