I have an array like
int outer[4][3] = {
{ 1, 2, 3 },
{ 2, 3, 5 },
{ 1, 4, 9 },
{ 10, 20, 30 }
};
我希望能够获得指向outer
中第n个一维数组的指针/数组。
void foo () {
printf("%d %d %d\n", outer[1][0], outer[1][1], outer[1][2]);
int inner[3] = outer[1]; /* Is there some way to do this assignment? */
printf("%d %d %d\n", inner[0], inner[1], inner[2]);
/* so that this line gives the same output as the first */
}
当然,使用指针数学运算也是可以实现的,但我感觉自己忘记了一些相关语法。