本帖最后由 bin554385863 于 2019-10-8 18:57 编辑
可以那么理解#include <iostream>
/*
type arr[k][j] = {......};
type (*p)[j] = arr;
则arr[k][j] = *(*(p+k)+j) = *(arr[k] + j)
*/
int main(int argc, char const *argv[])
{
int arr[2][2] = {0};
int (*p)[2] = arr;
for (size_t i = 0; i < 2; i++)
{
for (size_t j = 0; j < 2; j++)
{
std::cout<<*(*(p + i)+j);
}
std::cout<<std::endl;
}
std::cout<<std::endl;
for (size_t i = 0; i < 2; i++)
{
for (size_t j = 0; j < 2; j++)
{
std::cout<<*(arr[i] + j);
}
std::cout<<std::endl;
}
return 0;
}
|