At first it was found by mistake but I like this feature of C very interesting. a simple program like this :
#include <stdio.h>
#include <string.h>
main()
{
int array[5];
array[0] = 1;
printf("%d",0[array]);
}
will work with no compile error in C and it was not something that I expect. And it will print 1 in the out put. I found this amazing so I just wondering around and found this code will work fine in C too and this will print 10 in the output:
#include <stdio.h>
#include <string.h>
main()
{
int array[5];
array[0] = 1;
array[1] = 10;
printf("%d",0[array+1]);
}
I want to know why these two have no compilation error and also I want to know how the second one work at all. Also any interesting usage of this feature will be appreciated.