Remix.run Logo
rocqua 2 hours ago

That depends on sizeof(*arr) no?

unwind 2 hours ago | parent | next [-]

Not in C no, since arithmetic on a pointer is implicitly scaled by the size of the value being pointed at (this statement is kind of breaking the abstraction ... oh well).

messe an hour ago | parent | prev [-]

Nope, a[b] is equivalent to *(a + b) regardless of a and b.

sureglymop an hour ago | parent [-]

Given that, why don't we use just `*(a + b)` everywhere?

Wouldn't that be more verbose and less confusing? (genuinely asking)

tomsmeding an hour ago | parent [-]

Do you really think that `*(a + i)` is clearer than `a[i]`?