[try Beta version]
Not logged in

 
Arrays

Jun 15, 2013 at 11:38am
What does the statement below do?

 
    arr[arr[a]] = arr[2] + 5;
Jun 15, 2013 at 11:55am
Assigns the value stored in arr[2] to the element of array arr with index equal to arr[a].
Jun 15, 2013 at 12:05pm
remember that when vlad says "arr with index equal to arr[a]" you have to apply the pointer arithmetic to that arr[a], basically you obtain the right value by adding a to the memory address where arr starts/it's stored. You can read that as arr + a if you know what they mean.
Jun 15, 2013 at 12:07pm
@seven50
You can read that as arr + a if you know what they mean.


arr[a] is equivalent to *(arr + a)
Jun 15, 2013 at 12:26pm
yes, I was focusing on the arithmetic and I forgot the *, my bad.
Topic archived. No new replies allowed.