locate multiple characters in string

View versions (3)

INTERFACE

#include <string.h>
char strpbrk ( const char *s, const char *charset )

DESCRIPTION

The strpbrk function locates in the null-terminated string s 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 1
Workings

\code #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.
", strpbrk(s, t) - s); return 0; } \endcode

Solution

Output:

The position of the first binary digit of s is: 5.

SEE ALSO

memchr, strchr, strcspn, strrchr, strspn, strstr, strtok

STANDARDS

The strpbrk function conforms to ISO/IEC 9899:1990 ("ISO C90").