I was going over some statements for pointers in c on how to iterate through an array (A) starting at index 1. I was able to understand why the following works:
int* B = A; printf(“%dn”, B[i – 1]);
but when I saw that this one worked as well I got confused.
int* B = (&A)[0]; printf(“%dn”, B[i – 1]);
Could someone explain the logic behind (&A)[0]?
I was thinking (&A) gets the address for A, let’s say 0x8000, but I a not sure what [0] would do to an address
Amy Gregg is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.