Chapter Contents

Previous

Next
strpbrk

strpbrk



Find First Occurrence of Character of Set in String

Portability: ISO/ANSI C conforming, UNIX compatible


SYNOPSIS
DESCRIPTION
RETURN VALUE
CAUTION
EXAMPLE
RELATED FUNCTIONS
SEE ALSO


SYNOPSIS

#include <string.h>

char *strpbrk(const char *str, const char *cset);


DESCRIPTION

strpbrk locates the first occurrence in the first argument string ( str ) of a character in the second argument string ( cset ), returning a pointer to the character found.


RETURN VALUE

strpbrk returns a pointer to the requested character, or NULL if no character in the string is in the requested set of characters.


CAUTION

A protection or addressing exception may occur if either argument to strpbrk is not properly terminated.

See the function description for memscntb for information on possible interactions between the strpbrk and memscntb or strscntb functions.


EXAMPLE

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

main()
{
   char *line, *white, *temp;
   char input[80];

   puts("Enter some text:");
   line = gets(input);

      /* Locate the first white-space character in */
      /*  the line.                                */
   white = strpbrk(line, "\n\t\r\f\v ");
   puts("The first white space occurs after the word: ");

   for(temp = line;temp <= white;temp++)
   putchar(*temp);
   putchar('\n');
}


RELATED FUNCTIONS

strchr , strcspn , strscan , strtok


SEE ALSO


Chapter Contents

Previous

Next

Top of Page

Copyright © 2001 by SAS Institute Inc., Cary, NC, USA. All rights reserved.