Every story and comment from the Hacker News API, in a layout borrowed from 2001.
A comment on Switching to C over 'Modern' Programming Languages. Parent comment
Obviously, this isn't necessarily an improvement, but in theory you could do this:
size_t getlength( int m, char (*p) [m] ) { return sizeof *p; }
char mystring[] = "Hello"; getlength( sizeof mystring, &mystring )
There are no comments on this comment yet.
Obviously, this isn't necessarily an improvement, but in theory you could do this:
where you'd be calling it like this: But then you're back in "having to pass the length as a separate parameter" territory, I guess. (but at least it's the length of the array here, not just the zero-terminated component, which is what you wanted).