3 ms·
That’s not a good reason not to use it. A function can be not thread-safe and still safe to use in single-threaded programs. The point is that strtok is not a
by zakk 8y ago
That’s not a good reason not to use it.
A function can be not thread-safe and still safe to use in single-threaded programs.
The point is that strtok is not a good choice even for single-threaded code.
- johnisgood 8y ago> The point is that strtok is not a good choice even for single-threaded code. Why isn't it a good choice exactly? Could you sum it up?
- enriquto 8y agoMaybe he means that the function is not re-entrant. You cannot run a loop that tokenizes a string, and somewhere inside, you call a function that uses strtok itself. This can happen inadvertently.