www.delorie.com/djgpp/doc/libc/libc_779.html   search  
libc.a reference

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

strtok

Syntax

 
#include <string.h>

char *strtok(char *s1, const char *s2);

Description

This function retrieves tokens from s1 which are delimited by characters from s2.

To initiate the search, pass the string to be searched as s1. For the remaining tokens, pass NULL instead.

Return Value

A pointer to the token, or NULL if no more are found.

Portability

ANSI/ISO C C89; C99
POSIX 1003.2-1992; 1003.1-2001

Example

 
main()
{
  char *buf = "Hello there, stranger";
  char *tok;
  for (tok = strtok(buf, " ,");
       tok;
       tok=strtok(0, " ,"))
    printf("tok = `%s'\n", tok);
}

tok = `Hello'
tok = `there'
tok = `stranger'


  webmaster   donations   bookstore     delorie software   privacy  
  Copyright 2004   by DJ Delorie     Updated Apr 2004