4 ms·
Backward array index always had a use in the code golf context, like this: int a[3] = {0, 1, 2}; int *p = a; int **q = &p; int x = (*q)[1]; /
by omoikane 4y ago
Backward array index always had a use in the code golf context, like this:
int a[3] = {0, 1, 2};
int *p = a;
int **q = &p;
int x = (*q)[1]; // Read a[1]
int y = 1[*q]; // Same, but saves 2 bytes
Code golf considerations aren't always related to practicality, of course.
- zeusk 4y agoIf saving bytes is the goal, why not > int a[]={0,1,2}; > int y = a[1];
- pritambaral 4y agoIt's a demonstration, not real code. The first block of code is prologue, not main body.