programming.nbk: Home | Index | Next Page: strtoul(const char *str, char **endptr, int base) | Previous Page: strncpy(char *s1, const char *s2, size_t n)
Defined in string.h.
Scan string for specified characters.
Scans string1 character by character, returning a pointer to the first character that matches with any of the characters in string2. The search does not includes the terminating null-characters.
A pointer to the first appearance in string1 of a character specified in string2.
If none of the characters specified in string2 exists in string1, a NULL pointer is returned.
Defined in ANSI-C.
ANSI-C++ standard specifies two different declarations for this function instead of the one included in ANSI-C:
Both have the same behavior as the original declaration.
/* strpbrk example */ #include <stdio.h> #include <string.h> int main () { 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; } Output: Vowels in 'This is a sample string': i i a a e i
[strcspn], [strchr], [strrchr], [strstr]
programming.nbk: Home | Index | Next Page: strtoul(const char *str, char **endptr, int base) | Previous Page: strncpy(char *s1, const char *s2, size_t n)
Notebook exported on Monday, 7 July 2008, 18:56:06 PM Eastern Daylight Time