当前位置:网站首页>Distinction between pointer array and array pointer

Distinction between pointer array and array pointer

2022-04-23 19:29:00 ToneChip

Which of the following is an array pointer , Which is a pointer array :
A)
int *p1[10];
B)
int (*p2)[10];
Ask this question every class , There's always something you can't figure out . Here we need to understand a priority problem between symbols .

A)“[]” The priority ratio “*” higher .p1 With the first “[]” combination , The definition of an array , Array name p1,int * It modifies the contents of the array , That is, each element of the array . Now we know , This is an array , It contains 10 A point int Pointer to type data , It's a pointer array

B), ad locum “()” The priority ratio “[]” high ,“*” Number and p2 The definition that constitutes a pointer , The pointer variable name is p2,int It modifies the contents of the array , That is, each element of the array . Array has no name here , It's an anonymous array . Now we know p2 It's a pointer , It points to a containing 10 individual int An array of type data , Array pointer

版权声明
本文为[ToneChip]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204231923488506.html