Concept

Why is strtok() not reentrant, and what alternative does C provide?

ComputerScienceOne / Tokenizing

"It should be noted that strtok() is not reentrant. It can only work on one string at a time. In a multithreaded application, two threads cannot both use strtok() or they would end up processing each other’s strings. Even in a non-threaded application, we need to be careful. For example, we cannot process a string using strtok() in one function and then call another function that does the same. C does provide a reentrant version, strtok_r() that can be used."

Related Ideas

Why is strtok() not reentrant, and what alternative does C provide? | ComputerScienceOne | Bifalgorithm | Bifalgorithm