void printArray(int *array, int high, int wide)
{
for (int i = 0; i < high; ++i)
{
for (int j = 0; j < wide; ++j)
{
cout << *(array + i*wide + j) << " ";
}
cout << endl;
}
cout << endl;
}
int main()
{
int array[3][2] = { 1, 2, 3, 4, 5, 6 };
//比较下面三种传递的意思
printArray(*array, 3, 2);
printArray(*(array + 0) + 0, 3, 2);
// printArray(&array[0][0], 3, 2);
for (int i = 0; i < 3; ++i)
{
for (int j = 0; j < 2; ++j)
{
// cout << array[i][j] << " ";
cout << *(*(array + i) + j) << " ";
}
cout << endl;
}
system("pause");
return 0;
}
C/C++ 二维数组作为函数参数传递都会退化为指针
猜你喜欢
转载自blog.csdn.net/lpl312905509/article/details/101282010
今日推荐
周排行