Hacker News
new
|
past
|
comments
|
ask
|
show
|
jobs
|
submit
login
rocqua
13 days ago
|
parent
|
context
|
favorite
| on:
Addressing the adding situation
That depends on sizeof(*arr) no?
unwind
13 days ago
|
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).
reply
messe
13 days ago
|
prev
[–]
Nope, a[b] is equivalent to *(a + b) regardless of a and b.
reply
sureglymop
13 days ago
|
parent
[–]
Given that, why don't we use just `*(a + b)` everywhere?
Wouldn't that be more verbose and less confusing? (genuinely asking)
reply
tomsmeding
13 days ago
|
root
|
parent
[–]
Do you really think that `*(a + i)` is clearer than `a[i]`?
reply
sureglymop
13 days ago
|
root
|
parent
[–]
Not necessarily. I think it's confusing when there are two fairly close ways to express the same thing.
reply
Guidelines
|
FAQ
|
Lists
|
API
|
Security
|
Legal
|
Apply to YC
|
Contact
Search: