C-关于二维数组地址.这个陈述是什么意思


#include<stdio.h>
int main()
{
  int a[2][3] = {3,5,4,7,9,0};
  int i, j;
  for (i=0; i<2; i++)
  {
    for (j=0; j<3; j++)
    printf(“%pn”, *(a+i) +j); // Statment 1
  }
}

您可以看到,为什么标记的语句意味着它是二维array[a]的地址点?这是否意味着array[a]的值?我不明白星号是否意味着它从(a i)?

中获得了价值

这是我在Google上找到的示例

int a=9;
int *b = &a;
printf("%pn",b);

在Win32系统上,将打印以下结果:

0018FF20

您可以看到,指定符p用于获取指针当前指向的地址。

As a result *(a+i)+j would give you the address where the pointer is pointing in a 2-D array
As a result *(a+0)+0 would give you the 1st row and 1st column address
*(a+0)+1 would give you the 1st row and 2nd column address
*(a+1)+0 would give you the 2nd row and 1st column address.

最新更新