Mega Code Archive

 
Categories / C / Code Snippets
 

Scan string for specified characters how to use strpbrk

#include <stdio.h> #include <string.h> int main () { char str[] = "I Love Clementine"; 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; }