Unfortunately, I can't really find it now - there is a link to a question which claims to have a use for this syntax, but it's been removed.
There are these 2 comments: "Don't forget "Hello World"[i]. Or i["Hello World"] – Richard Pennington Jan 3 '10 at 15:12"
"Or, more usefully, "0123456789abcdef"[x & 0xf] "
Their basic point is that you can use this trick to find the i'th character in a string. Which I guess is useful sometimes...
---
Get the number of elements in an array:
#define ITEMSOF(arr) (sizeof(arr) / sizeof(0[arr]))
(0[arr] is identical to arr[0] for arrays but will intentionally fail if it's used against a C++ object that overloads operator[].)He gives a C++ template version, too.
---
... 10k+ users on Stack Overflow can see deleted stuff. Or you can probably get them out of the CC data dumps (but that's a lot more work than you want, probably). Or maybe out of the data explorer.
I personally prefer sizeof(*(arr)), which is the same as arr[0], but I suppose C++ lets you overload that as well.
Oh well. If you happen to find the funny but semi-legitimate one, I'd love to see it.
It's rumored to have been written by either Kernighan or Ritchie.
Funny enough, several people gave interesting places where this kind of syntax is a good thing. Goes to show that even meaningless pieces of fun on SO still end of enriching the reader.