3.2. strrchr

char *strrchr( const char *s, int c);
strrchr returns a pointer to last occurrence of c in s or NULL if not present.

The terminating '\0' of s is considered to be part of the string.

strrchr is like strchr, except it starts its search for the character at the end of the string and goes through the string in reverse order.

For example, if we have a path name like "/user/perry/osp/a1/main.c" and want to get a pointer to the filename part, "main.c",

we could use strrchr to search for the last slash:

        char *p = strrchr( path, '/');
        char *q = (p == NULL) ? path : p+1;     /* pointer to filename part */