Scan strings for characters in specified character sets.
#include <string.h> | Required only for function declarations |
char *strpbrk( const char *string1, const char *string2 );
char __far * __far _fstrpbrk( const char __far *string1,
const char __far *string2 );
string1 | Source string | |
string2 | Character set |
The strpbrk function finds the first occurrence in string1 of any character from string2. The terminating null character ('\0') is not included in the search.
The _fstrpbrk function is a model-independent (large-model) form of the strpbrk function. The behavior and return value of _fstrpbrk are identical to those of the model-dependent function strpbrk, with the exception that all the arguments and return values are far.
These functions return a pointer to the first occurrence of any character from string2 in string1. A NULL return value indicates that the two string arguments have no characters in common.
strpbrk
Standards:ANSI, UNIX
16-Bit:DOS, QWIN, WIN, WIN DLL
32-Bit:DOS32X
_fstrpbrk
Standards:None
16-Bit:DOS, QWIN, WIN, WIN DLL
32-Bit:None
/* STRPBRK.C */
#include <string.h>
#include <stdio.h>
void main( void )
{
char string[100] = "The 3 men and 2 boys ate 5 pigs\n";
char *result;
/* Return pointer to first 'a' or 'b' in "string" */
printf( "1: %s\n", string );
result = strpbrk( string, "0123456789" );
printf( "2: %s\n", result++ );
result = strpbrk( result, "0123456789" );
printf( "3: %s\n", result++ );
result = strpbrk( result, "0123456789" );
printf( "4: %s\n", result );
}
1: The 3 men and 2 boys ate 5 pigs
2: 3 men and 2 boys ate 5 pigs
3: 2 boys ate 5 pigs
4: 5 pigs