int *p=(*arrs);
for(int i=0;i<a_size;i++){
// std::cout<<i<<std::endl; //正确的方式
*p=i;
p++;
//不能用下面的语句,(*arrs)++会报lvalue required as increment operand错误,因为(*arrs)不是一个左值
//*(*arrs)=i;
//(*arrs)++;
}
return arrs;
}
int main()
{
int (*p)[10];
int arrs[]={1,2,3,4,5,0,0,0,0,0};
//不能是p=functions(arrs,10),因为是函数需要传一个数组指针而不是首地址指针
p=functions(&arrs,10);
for(auto c:(*p)){
std::cout<<c<<std::endl;
}
}来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/30221425/viewspace-2142716/ ,如需转载,请注明出处,否则将追究法律责任。