Scan string for specified characters: how to use strpbrk
#include <stdio.h>
#include <string.h>
int main ()
{
char str[] = "This is a line";
char key[] = "aeiou";
char *p;
printf ("Vowels in '%s': ",str);
p = strpbrk (str, key);
while (p != NULL) {
printf ("%c " , *p);
p = strpbrk (p + 1, key);
}
printf ("\n");
return 0;
}
Related examples in the same category