J
Jonathan Burd
Greetings everyone,
I have noticed a little quirk in C's array-indexing syntax.
I wonder what practical purpose this little "inverting" serves
to be included in the standard (it compiles fine with
gcc -pedantic -Wall -std=c89 and executes properly when run).
The code follows:
#include <stdio.h>
#define A_MAX (5)
int
main (int argc, char ** argv)
{
int a[A_MAX] = {0, 1, 2, 3, 4};
int i;
for (i = 0; i < A_MAX; ++i)
printf ("%d\n", i[a]); /* <<-- inside-out */
return 0;
}
Any help will be appreciated.
Regards,
Jonathan.
I have noticed a little quirk in C's array-indexing syntax.
I wonder what practical purpose this little "inverting" serves
to be included in the standard (it compiles fine with
gcc -pedantic -Wall -std=c89 and executes properly when run).
The code follows:
#include <stdio.h>
#define A_MAX (5)
int
main (int argc, char ** argv)
{
int a[A_MAX] = {0, 1, 2, 3, 4};
int i;
for (i = 0; i < A_MAX; ++i)
printf ("%d\n", i[a]); /* <<-- inside-out */
return 0;
}
Any help will be appreciated.
Regards,
Jonathan.