Does every token that strtok() creates end with a null byte in C?

From the man page:

Each call to strtok() returns a pointer to a nul-terminated string containing the next token.

So the short answer is “Yes”. Think about it. If the return was not nul terminated then it wouldn’t be tokenizing because you wouldn’t just get the token, you’d get the token and the rest of the string as well…

Leave a Comment