Mega Code Archive

 
Categories / C / String
 

Scan string for specified characters

#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; }