3 ms·
Exactly. There is also "strsep"[1]. [1] https://man.openbsd.org/strsep.3 https://man.openbsd.org/strsep.3
by johnisgood 2y ago
Exactly. There is also "strsep"[1].
[1] https://man.openbsd.org/strsep.3 https://man.openbsd.org/strsep.3
- kstrauser 2y agoDoesn't that modify the input in exactly the same way strtok does?
- duskwuff 2y agoThe worst problem with strtok() isn't that it modifies its input; it's that it's stateful. It retains a pointer to the input string internally, and returns subsequent words from it when called with an input of NULL. strsep() fixes this by using a char * argument instead.
- duskwuff 2y ago... and HN's formatting mangled that, yay. I meant a char ** argument.