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
- How can you tokenize a String in Java?ComputerScienceOne · Tokenizing
- How can PHP split strings into tokens using explode() and preg_split()?ComputerScienceOne · Tokenizing
- How do sscanf() and sprintf() work with strings?ComputerScienceOne · Tokenizing
- How can strlen determine the length of a C string?ComputerScienceOne · String Library
- How can you create an array of strings in C?ComputerScienceOne · Arrays of Strings
- How can you create static strings with character arrays?ComputerScienceOne · Character Arrays
- How can you compute a substring of a string?ComputerScienceOne · Arrays of Strings
- What are PHP strings and how should they be treated?ComputerScienceOne · Basics