Difference between two declarations involving a pointer and an array

后端 未结 6 1248
臣服心动
臣服心动 2020-12-18 11:45

What is the difference between int *a[3] and int (*a)[3]?

6条回答
  •  情深已故
    2020-12-18 11:54

    There is no difference between int a[3] and int (a)[3], they both declare a as an array of 3 ints. There is a difference between int *a[3] and int (*a)[3], the former declares an array of 3 pointers to int whereas the second declares a pointer to an array of 3 ints. The parenthesis make a difference here because in C brackets have a higher precedence than *.

提交回复
热议问题