Share this page

# Example: strrchr

The following example uses strrchr to find the last instance of the character `x' in the string, string.

        #include <string.h>

        char * string = "His Excellency the Duke of Exeter";
        char * first_x, * last_x;
        first_x = (char *)strchr(string, 'x');
        lr_output_message ("The first occurrence of x: %s", first_x);
        last_x = (char *)strrchr(string, 'x');
        lr_output_message ("The last occurrence of x: %s", last_x);

    Example: Output:
    Action.c(7): The first occurrence of x: xcellency the Duke of Exeter
    Action.c(10): The last occurrence of x: xeter

Tips to improve your search results... VuGen Function Reference Version 25.1-25.3 Function Reference 25.1-25.3 All View Local Help Center View Online Help Center Version: