|
|
|
|
|
by flohofwoe
3946 days ago
|
|
Doesn't the C version have a serious bug? If the input string has 12 or more characters, the destination string will not be zero-terminated. From the strncpy docs: "No null-character is implicitly appended at the end of destination if source is longer than num. Thus, in this case, destination shall not be considered a null terminated C string (reading it as such would overflow)." |
|
And often times I'll be memset()'ing the destination to all NULLs when doing a string copy operation. I'm not real happy with string handling in C... as if that should be surprising to anyone.
Say, is there nice, small, suitable for embedded use string library anyone would care to recommend in C? I just want a nice string type that carries around its length and storage length, handles copies properly, and has the usual utilities. I suppose I could just write one...