cvs.delorie.com/djgpp/doc/libc/libc_773.html   search  
libc.a reference

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

strsep

Syntax

 
#include <string.h>

char *strsep(char **stringp, char *delim);

Description

This function retrieves the next token from the given string, where stringp points to a variable holding, initially, the start of the string. Tokens are delimited by a character from delim. Each time the function is called, it returns a pointer to the next token, and sets *stringp to the next spot to check, or NULL.

Return Value

The next token, or NULL.

Portability

ANSI/ISO C No
POSIX No

Example

 
main()
{
  char *buf = "Hello  there,stranger";
  char **bp = &buf;
  char *tok;
  while (tok = strsep(bp, " ,"))
    printf("tok = `%s'\n", tok);
}

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


  webmaster     delorie software   privacy  
  Copyright © 2004     Updated Apr 2004