C examples for string.h:strpbrk
function
<cstring> <string.h>
Locate characters in string
const char * strpbrk ( const char * str1, const char * str2 ); char * strpbrk ( char * str1, const char * str2 );
Parameter | Description |
---|---|
str1 | C string to be scanned. |
str2 | C string containing the characters to match. |
A pointer to the first occurrence in str1 of any of the characters that are part of str2.
If none of the characters of str2 is present in str1, a null pointer is returned.
#include <stdio.h> #include <string.h> int main ()/*from w ww . j av a 2 s .c om*/ { char str[] = "This is a sample string"; char key[] = "aeiou"; char * pch; printf ("Vowels in '%s': ",str); pch = strpbrk (str, key); while (pch != NULL) { printf ("%c " , *pch); pch = strpbrk (pch+1,key); } printf ("\n"); return 0; }