Tuesday, January 22, 2008

A simple fact abt Arrays

Consider the following array:

int a[5]={1, 2, 3, 4, 5};

a[i] == * (a + i)

* (a + i) == * (i + a)

* (i + a) = i[a]

yes, a[i] == i[a], both are same.

In this example 'a' is not a pointer the array. 'a' is just a value or constant. A pointer is an Variable, it means it's value can be modified.

'a' is a pointer constant, it is an address. That's why you can't put 'a' in the left hand side of the equation. 'a' is not an L-value.

No comments: