scanf("%d",((*a + i)+ j))和scanf("%d",&a [i] [j])之间的差异

Jai*_*ach 2 c arrays

根据我的理解,[i] [j]可以像*(*a + i)+ j一样读取,但我用其中两种表示法扫描扫描,我看到差异,下面是代码片段,

for (i=0;i<3;i++)
    {
        for(j=0;j<3;j++)
        {
    //      scanf("%d",((*a+i)+j));
            scanf("%d",&a[i][j]);
            printf("Address of &a[%d][%d]=%ld , Adress of ((*a+%d)+%d)=%ld\n",i,j,&a[i][j] ,i,j, ((*a+i)+j));
        }
    }
Run Code Online (Sandbox Code Playgroud)

我低于输出,

1
Address of &a[0][0]=140736658532752 , Adress of ((*a+0)+0)=140736658532752
2
Address of &a[0][1]=140736658532756 , Adress of ((*a+0)+1)=140736658532756
3
Address of &a[0][2]=140736658532760 , Adress of ((*a+0)+2)=140736658532760
4
Address of &a[1][0]=140736658532772 , Adress of ((*a+1)+0)=140736658532756
5
Address of &a[1][1]=140736658532776 , Adress of ((*a+1)+1)=140736658532760
6
Address of &a[1][2]=140736658532780 , Adress of ((*a+1)+2)=140736658532764
7
Address of &a[2][0]=140736658532792 , Adress of ((*a+2)+0)=140736658532760
8
Address of &a[2][1]=140736658532796 , Adress of ((*a+2)+1)=140736658532764
9
Address of &a[2][2]=140736658532800 , Adress of ((*a+2)+2)=140736658532768
Run Code Online (Sandbox Code Playgroud)

请有人,请介绍两种情况下的记忆表示......

R S*_*ahu 7

你说,

根据我的理解,[i] [j]可以像*(*a + 1)+ j一样读取,但我用其中两种表示法扫描扫描,我看到差异,下面是代码片段,

我猜你有一个错字.你的意思是*(*a+i)+j代替*(*a+1)+j.

然而,这也不是真的.

a[i]相当于*(a+i),而不是(*a+i).由于运算符优先级,*a+i相当于(*a)+i,而不是*(a+i).

同样,a[i][j]相当于*(*(a+i)+j),而不是*(*a+1)+j.