I was experimenting some stuff with pointers in my school today when i found that the following code would output
1
2
3
4
5
6
7
8
9
Here is the code:
int foo[10];
int i;
for (i = 0; i < 10; i++)
foo[i] = i;
for (i= 0; i < 10; i++)
printf("%d\n", i[foo]);
I have been looking for an explanation on the internet but I can't seem to find one.