Actions

EmSys

C - Pointers and Arrays2

From EdWiki

Revision as of 09:30, 23 June 2015 by Jshankar (Talk | contribs) (1 revision imported: EdWiki -- Emsys pages from Shukra)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Pointers and Arrays ...

If pa is a pointer to an integer declared as

int* pa;

Then the assignment

pa = &ar[0];

Sets pa to point to element zero of ar; i.e, pa contains the address of ar[0].

Since the name of an array is a synonym for the location of the initial element, the assignment pa = &ar[0] can also be written as pa = ar.

Now the assignment

x = *pa;

Will copy the contents of ar[0] into x.