Difference between *ptr[10] and (*ptr)[10]

前端 未结 6 1417
自闭症患者
自闭症患者 2020-12-04 17:29

For the following code:

    int (*ptr)[10];
    int a[10]={99,1,2,3,4,5,6,7,8,9};
    ptr=&a;
    printf(\"%d\",(*ptr)[1]);

What should

6条回答
  •  不知归路
    2020-12-04 17:29

    int *ptr[10];

    This is an array of 10 int* pointers, not as you would assume, a pointer to an array of 10 ints

    int (*ptr)[10];

    This is a pointer to an array of 10 int

    It is I believe the same as int *ptr; in that both can point to an array, but the given form can ONLY point to an array of 10 ints

提交回复
热议问题