Files
marissa.sam/task2/strtok_tryout.cpp
louiscklaw bfa5b5ff46 update,
2025-02-01 02:04:02 +08:00

23 lines
376 B
C++

#include <string.h>
#include <stdio.h>
int main()
{
char str[80] = "This is - www.tutorialspoint.com - website";
const char s_delimit[2] = "-";
char *token;
/* get the first token */
token = strtok(str, s_delimit);
/* walk through other tokens */
while (token != NULL)
{
printf("%s\n", token);
token = strtok(NULL, s_delimit);
}
return (0);
}