Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Address-of operator in C

In C programming, does the address-of operator & result in object’s first address?

For example:

int a[2] = {10, 20};   
int* arrays_first_address = &a;

As &a means "array’s first address" then can I generalize it so the address-of operator results in object’s first address?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

int a[2];

If you use &a it will give you address of a[0].

&a = &a[0]

array name is pointer to its 0th element, that is base address.

Then you can use base address to get address of other locations.
such as &a[1] = (a + 1).

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading