C Standard Libraries C++

strrchr()

Declaration

char* strrchr(const char* kcpString, int iChar);

Description

This function returns a pointer to the last occurrence of "iChar" in the string "kcpString." If no occurrence is found, the function returns NULL.

Example

#include <cstdio>
#include <cstring>

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

    return 0;
}

Output

strrchr() Output
 

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