Find token with strrtok function - C String

C examples for String:String Function

Description

Find token with strrtok function

Demo Code

#include <stdio.h>
#include <string.h>

int main(void)
{
    char data[] = " this is a test C is\t  too#much\nfun!";
    const char tokseps[] = " \t\n#"; /* separators  */
    char * pt;// w  ww  . j ava  2 s .  co  m
    
    puts(data);
    pt = strtok(data,tokseps);       /* intial call  */
    while (pt)                       /* quit on NULL */
    {
        puts (pt);                   /* show token   */
        pt = strtok(NULL, tokseps);  /* next token   */
    }
    return 0;
}

Result


Related Tutorials