3 ms·
Don't use sizeof. If you pass in a pointer you're going to get the size of the pointer, not the length of the string buffer.
by mlindner 5y ago
Don't use sizeof. If you pass in a pointer you're going to get the size of the pointer, not the length of the string buffer.
- tedunangst 5y agoBut no suggestion for an alternative?
- mlindner 5y agoThere's a lot of alternatives, none of them I particularly like best for all cases. So I won't suggest something I don't think is very good. sizeof is particularly bad however for any kind of strings.
- savannape 5y agosizeof would give you the actual size if you pass in a statically declared array.