对数组指针的理解

    技术2022-05-19  20

     

    #include <stdio.h>

    int main()

    {

        int szTest[5][10];

        int n1 = &szTest[4]-&szTest[0];

        int n2 = &szTest[3][1]-&szTest[1][3];

        printf("n1=%d/nn2=%d/n", n1, n2);

        return 0;

    }

    输出

    n1=4

    n2=18

     

    个人理解:

    &szTest[4]-&szTest[0]可以看作是szTest[4]指针-szTest[0]指针

    而&szTest[3][1]-&szTest[1][3]可以看作是szTest[3][1]指针-szTest[1][3]指针


    最新回复(0)