Sorry for probably a stupid question but, after reading a considerably amount of examples I still don't understand how strtok()
works.
Here is example:
char s[] = " 1 2 3"; // 3 spaces before 1
int count = 0;
char* token = strtok(s, " ");
while (token != NULL) {
count++;
token = strtok(NULL, " ");
}
After executing count
equals 3. Why?
Please explain I've given detailed steps of what happens inside the call to that function.