3 ms·
> it writes zeros to the input array [which] means it's unfit for most use cases[...] Other issues with strtok() aside, this seems like a silly reason to disco
by avar 8y ago
> it writes zeros to the input array [which] means it's unfit for most use cases[...]
Other issues with strtok() aside, this seems like a silly reason to discount a standard library function. If you don't want your input munged you can strdup() it. It's rare to find a C program that's so specialized that the performance hit of a strdup() would be unacceptable in a case where strtok() could otherwise have been used.
- jstimpfle 8y agoIt would be wasteful to duplicate the input string which includes so much garbage. I would rather just go through the input string and append token by token to the output string, terminated with a single NUL.