3 ms·
The main difficulty with strings in C is caused by arrays decaying to pointers whenever passed to a function. My article about it: http://digitalmars.com/arti
by WalterBright 11y ago
The main difficulty with strings in C is caused by arrays decaying to pointers whenever passed to a function.
My article about it:
http://digitalmars.com/articles/b44.html http://digitalmars.com/articles/b44.html
- joveian 11y agoI just recently discovered that modern C actually has syntax for forcing sized arrays as function arguments. You can do: foo(size_t n, char arr[restrict static n]) The static qualifier here means "no really, I actually want the compiler to complain if the passed array isn't the size indicated". (because C doesn't have enough different meanings for the word "static" :( ). I haven't seen this in the wild yet or checked if gcc and clang actually implement it usefully, but it seems like it could be quite useful.