strpbrk
Locate multiple characters in string
Description
The strpbrk function locates in the null-terminated strings
the first occurrence of any character in the string charset
and returns a pointer to this character. If no characters from charset
occur anywhere in s
strpbrk returns NULL.
Example:
Example - Locate multiple characters in string
Workings
#include <stdio.h> #include <string.h> int main() { char s[20] = "abcde1010101", t[3] = "01"; printf("The position of the first binary digit of s is: %d.\n", strpbrk(s, t) - s); return 0; }
Solution
Output:
The position of the first binary digit of s is: 5.