C Standard Libraries C++

strpbrk()

Declaration

char* strpbrk(const char* kcpString, const char* kcpChars);

Description

This function returns a pointer to the first occurrence of a character in the null-terminated set "kcpChars" that is inside the null-terminated string "kcpString."

Example

#include <cstdio>
#include <cstring>

int main()
{
    char caString[] = "XoaX.net";
    char caChars[] = "aei";
    // Find the first of "aei" inside of "XoaX.net"
    char* cpFound = strpbrk(caString, caChars);
    int iPos = (cpFound - caString);
    printf("First of %s found at %i\n", caChars, iPos);

    return 0;
}

Output

strpbrk() Output
 

© 2007–2024 XoaX.net LLC. All rights reserved.