Hacker News new | ask | show | jobs
by bluetomcat 2895 days ago
> Adding an array type to C that knows its own length would solve so many headaches

C arrays know their length, it's always `sizeof(arr) / sizeof(*arr)`. It's just that arrays become pointers when passed between functions, and dynamically-sized regions (what is an array in most other languages) are always accessed via a pointer.

1 comments

He said "array type". There isn't one in C.

"It's just that arrays become pointers when passed between functions"

Oh, is that all?

Did you read the article, or the comment you're responding to? They point out the cost of "just" doing that.