3 ms·
> does it also rely on the programmer setting the size_t value correctly? For static arrays, no, the compiler does it. For turning pointers into phat pointers,
by WalterBright 8y ago
> does it also rely on the programmer setting the size_t value correctly?
For static arrays, no, the compiler does it. For turning pointers into phat pointers, yes, the user has to supply the length. But he only has to do that once.
> exactly the same
It isn't, for the reasons:
1. The compiler knows about it, so it can be used for optimization purposes, and to optionally insert bounds checking or not.
2. Consider why C has structs. It's because it's a lot less error prone to group related values together, rather than having a collection of independent variables. It makes the code easier to read, too.