// crt_strtok.c
// compile with: /W3
// In this program, a loop uses strtok
// to print all the tokens (separated by commas
// or blanks) in the string named "string".
//
char str[] = "123;qwe;3432;rer";
char seps[] = ";";
char *token;
int main( void )
{
printf( "Tokens:\n" );
// Establish string and get the first token:
token = strtok( str, seps ); // C4996
// Note: strtok is deprecated; consider using strtok_s instead
while( token != NULL )
{
// While there are tokens in "string"
printf( " %s\n", token );
// Get next token:
token = strtok( NULL, seps ); // C4996
}
}