When int a[3] has been defined, is there any difference between int* b = a and int (*c)[3] = &a

后端 未结 3 1374
小鲜肉
小鲜肉 2021-01-27 07:06

I\'m trying to deepen my understanding on syntax relevant to pointer in C, and I noticed that If I created an array of int first, int(*)[] is a way of giving a poin

3条回答
  •  不思量自难忘°
    2021-01-27 07:42

    So I'm confused what's the difference between pointer b and pointer c in Code below?

    Their types. b is of type int *, and c is of type int (*)[3].

    The address of the array is the same as the address of the first element in the array, so the memory location they point to will be same here, but as per their types, operations on them, for example pointer arithmetic will produce completely different results.

提交回复
热议问题