可能重複:
C pointer to array/array of pointers disambiguation *和[]中哪一個在C中最強?
在C中,是int *thing[5]
五個指針的數組,每個指向的整數,或指向的五個整數數組?
可能重複:
C pointer to array/array of pointers disambiguation *和[]中哪一個在C中最強?
在C中,是int *thing[5]
五個指針的數組,每個指向的整數,或指向的五個整數數組?
[]
王牌*
每C precedence table這意味着你有一個五個int指針的數組。
也許是重複的......它是一個由五個指向整數的指針組成的數組;在類似的問題中引用的程序cdecl
可以爲新手有用:
cdecl> explain int *t[5];
declare t as array 5 of pointer to int
如有疑問,使用括號 - 維護程序員會感謝你
缺席任何顯式的分組與括號,既有數組下標操作者[]
和函數調用操作()
綁定之前*
,所以
T *a[N]; -- a is an N-element array of pointer to T
T (*a)[N]; -- a is a pointer to an N-element array of T
T *f(); -- f is a function returning pointer to T
T (*f)(); -- f is a pointer to a function returning T
這從語法如下(取。1.從哈比森&斯蒂爾,第5版,附錄B):
declarator: pointer-declarator direct-declarator pointer-declarator: pointer direct-declarator pointer: * type-qualifier-listopt * type-qualifier-listopt pointer direct-declarator: simple-declarator (declarator) function-declarator array-declarator function-declarator: direct-declarator (parameter-type-list) direct-declarator (identifier-listopt) array-declarator: direct-declarator [ constant-expressionopt ] direct-declarator [ array-qualifier-listopt array-size-expressionopt ] direct-declarator [ array-qualifier-listopt * ]
另外: 'CDECL>解釋INT(*東西)[5] - > 聲明東西作爲指針INT的陣列5 ' 這給出了一個他詢問的5個整數的指針。 – 2010-06-24 16:19:48