nytpu on Nostr: Just learned possibly the most cursed C fact IMO: array[i] is equivalent to *(array + ...
Just learned possibly the most cursed C fact IMO: array[i] is equivalent to *(array + i) per the spec, which means i[array] works exactly the same, since the + operator is commutative. It also works for multidimensional/nested arrays and the “outside” index doesn't even need to be a symbol, so you can even do things like 0[array]1, equivalent to array[0][1] and *(*(array + 0) + 1). This is a new level beyond pointer decay, which generally makes sense even if it's irritating
Per: gemini://foo.zone/gemfeed/2024-07-05-random-weird-things.gmi
Published at
2024-07-11 13:58:07Event JSON
{
"id": "66624d0cbd9b86ca293ed98dce0836dede811dccb56fccc42c1417f9ecc11cda",
"pubkey": "8ee1c91655d21e5f4378904ed1626213513b9582b20b5a9c9b434060e9302d6e",
"created_at": 1720706287,
"kind": 1,
"tags": [
[
"proxy",
"https://tilde.zone/users/nytpu/statuses/112768207274233078",
"activitypub"
]
],
"content": "Just learned possibly the most cursed C fact IMO: array[i] is equivalent to *(array + i) per the spec, which means i[array] works exactly the same, since the + operator is commutative. It also works for multidimensional/nested arrays and the “outside” index doesn't even need to be a symbol, so you can even do things like 0[array]1, equivalent to array[0][1] and *(*(array + 0) + 1). This is a new level beyond pointer decay, which generally makes sense even if it's irritating\n\nPer: gemini://foo.zone/gemfeed/2024-07-05-random-weird-things.gmi",
"sig": "9cadf66d798621e28ce6f3cf6ac59115c9a52e83ab183ac9421ed1eeb580e7017c46b785e6a77681f27db65ca88641c7bb7ae0f8e1a0d76b235a476289f1fb6c"
}