by anticensor · 7y ago · 0 comments
typedef struct thing {
char a;
long long int nothing;
} thing_t;
#define P(x) printf("%s %c\n", #x, x)
int main(int argc, char **argv)
{
thing_t array[1024];
array[8].a = 'H';
P(array[8].a);
P((8[array]).a);
P((*(8 + array)).a);
} foo[3]
*(foo + 3)
*(3 + foo)
3[foo]
They all do the same thing. foo[3] == (void *)((usize)foo + (usize)(3 * sizeof(*foo)))You can also subtract two pointers into the same array and get the distance (in elements, not bytes). a[b - a] == b.