[英]What is the difference between these two C declarations?
我今天接受采訪時被問到以下兩個聲明之間的區別:
int *A[10];
和
int (*A)[10];
我不知道。 如果你認為我錯過了一些重要的指針'指針',請告訴我。 謝謝。
第一個聲明一個十個指向int
的數組,第二個指向一個十個int
數組的指針。
[]
綁定比*
更緊密,所以第一個可以等效地寫入
int *(A[10]);
特定
int *A[10]; // an array of 10 int pointers
一元*
和[]
的相對優先級使其相當於
int *(A[10]); // same
第二個聲明將隱式排序更改為
int (*A)[10]; // a pointer to an array of ten ints
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.