Trying to understand array notations
arrays, c
Solution
Here you have declared array of pointers. At first you should know the various representation of array. How a[i] is calculate? a gives you the base address of array.
a[ i ] = *(a+i)
(*a)[0] = *(*a+0)
(*a)[1] = *(*a+1)
Thus the value of (*a)[0] = *(address of i + 0) = Value of i
And the value of (*a)[1] = *(address of i + 1) = value at the location of (add of i + 2) i.e. a garbage value.
In above problem you can get the value correctly if you use *( a[ 0 ] ) and *( a[1] ).
Problem
in the following code : ``` int main() { int i = 15, j = 1; int *a[] = {&i, &j}; printf("%d", (*a)[0]); return 0; } ``` the output of `(*a)[0]` is `15` (value of i) however when I tried to check `(*a)[1]` it gives a garbage value. I would expect that the same expression should work for all the entries in the array however it works only for the first element in the array.