4 ms·
> 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
by bluetomcat 8y 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.
- jibal 8y agoHe 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.