|
|
![]() |
![]() |
![]() |
C++ Reference: strtok()
strtok()
Declaration
char* strtok(char* cpString, const char* kcpDelimiters);
Description
This function returns a pointer to the first character of "cpString" in the null-terminated set "kcpDelimiters." Once a delimiter is found, it is replaced by a NULL or '\0' character. So, repeated calls continually find the next delimiter in the string.
Example
#include <cstdio>
#include <cstring>
int main()
{
char caString[] = "Copyright 2009 XoaX";
char caDelim[] = " ";
char* cpSub = strtok(caString, caDelim);;
// Get the next token until, there are no more.
while (cpSub) {
printf("%s \n", cpSub);
cpSub = strtok(NULL, caDelim);
}
return 0;
}
Output:
![]() |
![]() |
![]() |
| Home | | | Reference | | | Play Games! | | | Forum | | | Site Map | | | Contact Us |






