Definition | #include <string.h> char *strtok(char *s1, const char *s2);
To ensure that | |
Return val. | Pointer to the beginning of a token. | |
At the first call, a pointer to the first token; at the next call, a pointer to the following token, etc. | ||
NULL pointer | if no token, or no further token was found. | |
Example | #include <string.h>
#include <stdio.h>
int main(void)
{
static char str[] = "?a???b,,,#c";
char *t;;
t = strtok(str, "?"); /* t points to the token "a" */
t = strtok(NULL, ","); /* t points to the token "??b" */
t = strtok(NULL, "#,"); /* t points to the token "c" */
t = strtok(NULL, "?"); /* t is a NULL pointer */
return 0;
}
| |