int a[10];
int *p = a; //way 1
int *p1 = &a[0]; //way 2
Could you tell me the differences between two ways above?
There is no difference. Both assign the address of the first element to the pointer p
and p1
respectively.
In the first case, a
is automatically converted to the address of the first element. In the second case it uses the address of the first element explicitly.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.