Next: memset, Previous: mempcpy, Up: Strings [Contents][Index]

### 5.12 `memrchr`—reverse search for character in memory

Synopsis

    #include <string.h>
    void *memrchr(const void *src, int c, size_t length);

Description
This function searches memory starting at length bytes beyond `*src` backwards for the character c. The search only ends with the first occurrence of c; in particular, `NUL` does not terminate the search.

Returns
If the character c is found within length characters of `*src`, a pointer to the character is returned. If c is not found, then `NULL` is returned.

Portability
`memrchr` is a GNU extension.

`memrchr` requires no supporting OS subroutines.