#include <stdio.h>
#include <string.h>
int main()
{
char string[] = "asd fasd fasdf asdfads fasdf";
char *tokenPtr;
printf( "%s\n%s\n\n%s\n",
"The string to be tokenized is:", string,
"The tokens are:" );
tokenPtr = strtok( string, " " );
while ( tokenPtr != NULL ) {
printf( "%s\n", tokenPtr );
tokenPtr = strtok( NULL, " " );
}
return 0;
}
The string to be tokenized is:
asd fasd fasdf asdfads fasdf
The tokens are:
asd
fasd
fasdf
asdfads
fasdf
24.21.strtok |
| 24.21.1. | Using strtok |