3 ms·
which would also illustrate what K&R said about array indices just being syntactic sugar for pointer arithmetic. My mind has been blown.
by discojesus 17y ago
which would also illustrate what K&R said about array indices just being syntactic sugar for pointer arithmetic.
My mind has been blown.
- gjm11 17y agoIf that blows your mind, you might want to avoid looking at the following: "foo"[2] == ("foo"+2) == (2+"foo") == 2["foo"]. And yes, you really can do that: in general a[b] and b[a] are exactly the same thing in C.
- scott_s 17y agoMore C array pointer fun: *("abcdefg" + 3) == 'd'
- bhousel 17y agosure as long as you don't care about stuff like unicode..
- hc 17y agonot quite. "foo"[2] is a char, ("foo"+2) is a string.
- gjm11 17y agooh, bother, I forgot what HN does to asterisks. In what I wrote above, look for the bit in italics and mentally insert asterisks on each side of it. It was right when I typed it in, I promise...