M
matevzb
Since array subscripting is commutative in C, is the following
perversity legal and/or portable? (I don't really intend to use it
anywhere, it just puzzles my mind.)
#include <stdio.h>
int
fcn (void)
{
return 3;
}
int
main (void)
{
int array[] = { 1, 2, 3, 4, 5, 6, 7, 9 };
printf ("%d\n", fcn()[array]);
return 0;
}
It looks a bit confusing though, since the usage resembles the
following:
#include <stdio.h>
int *
fcn2 (void)
{
static int array2[] = { 5, 4, 3, 2, 1, 0 };
return array2;
}
int
main (void)
{
printf ("%d\n", fcn2()[3]);
return 0;
}
perversity legal and/or portable? (I don't really intend to use it
anywhere, it just puzzles my mind.)
#include <stdio.h>
int
fcn (void)
{
return 3;
}
int
main (void)
{
int array[] = { 1, 2, 3, 4, 5, 6, 7, 9 };
printf ("%d\n", fcn()[array]);
return 0;
}
It looks a bit confusing though, since the usage resembles the
following:
#include <stdio.h>
int *
fcn2 (void)
{
static int array2[] = { 5, 4, 3, 2, 1, 0 };
return array2;
}
int
main (void)
{
printf ("%d\n", fcn2()[3]);
return 0;
}