Jump to: navigation, search

Description

The strpbrk() function locates the first occurrence in the string pointed to by s1 of any character from the string pointed to by s2.

Return value

The strpbrk() function returns a pointer to the character, or a null pointer if no character from s2 occurs in s1.

Prototype

Declared in string.h

The C89/C99 prototype is:

char *strpbrk(const char *s1, const char *s2);

Implementation

In standard C, this can be implemented as:

#include <string.h> /* strchr */
char *strpbrk(const char *s1, const char *s2)
{
    while(*s1)
        if(strchr(s2, *s1++))
            return (char*)--s1;
    return 0;
}

Compilable unit, portable C90 in implementation namespace; public domain; past reviewers: none; current reviews: none

References

The C Standard, 7.21.5.4 (C99 numbering)

Personal tools