Hacker News

Favorites Setup
Comment by skydhash | original | C for Rust programmers
[−]skydhash · 2026-10-10 Sat 15:29 UTC · link
> It's not something people want or care about, it's just a tedious detail.

It’s not something idiomatic, but indexing in C is syntactic sugar. Not sure why they allow it in the syntax, but forgetting that arrays are pointers and not special type is just asking for bugs.

[−]im3w1l · 2026-10-10 Sat 15:42 UTC · link
Arrays are not pointers in c. Though they are very similar and will implicitly convert, there are differences. The big and obvious difference is that declaring an array will allocate space for it. In a function, on the stack. In a struct, inline. They have different sizeof. I think there are also some other stuff I can't remember.
[−]ynik · 2026-10-10 Sat 18:08 UTC · link
In C there's only two operations you can do with arrays that do not decay to a pointer: `sizeof(array_var)` and `&array_var`. The latter produces a rarely-seen "pointer to array", i.e. a type like `int (*)[10]` (pointer-to-array syntax works like pointer-to-function syntax).
[−]uecker · 2026-10-11 Sun 08:39 UTC · link
Luckily I start to see such pointers used more often, because such pointers can be used for bounds checking because the size is preserved in the type.