How can a function in C maintain it's internal state?
For example strtok()
- when calling strtok(NULL, del)
the function continue working on a previous string.
It contains internal variables to keep track of things, declared as static
. This is also the very reason why such functions aren't safe to use in multi-threaded programs.