3 ms·
On the contrary, I think "Strings are just character arrays are just pointers" is the solution, not the problem. As with non-character arrays, you must always p
by lultimouomo 6y ago
On the contrary, I think "Strings are just character arrays are just pointers" is the solution, not the problem. As with non-character arrays, you must always pair the pointer with a length. (I don't like the idea of prefixing the length because it prevents su stringing).
The problem is the null termination, which is not general to arrays (though it is sometimes used with arrays of pointers).
- ByteJockey 6y agoYou sometimes see sentinel values used with varargs (only if they're all the same type), which is basically just an array with more boilerplate. That being said. Length as a first parameter and the rest of the arguments being the variadic bit is also quite normal.