strrchr, wcsrchr, _mbsrchr
Scan a string for the last occurrence of a character.
char *strrchr( const char *string, int c ); wchar_t *wcsrchr( const wchar_t *string, wchar_t c ); unsigned char *_mbsrchr( const unsigned char *string, unsigned int c );
Parameters
- string
- Null-terminated string to search.
- c
- Character to be located.
Return Value
Returns a pointer to the last occurrence of c in string, or NULL if c is not found.
Remarks
The strrchr function finds the last occurrence of c (converted to char) in string. The search includes the terminating null character.
wcsrchr and _mbsrchr are wide-character and multibyte-character versions of strrchr. The arguments and return value of wcsrchr are wide-character strings; those of _mbsrchr are multibyte-character strings. These three functions behave identically otherwise.
Generic-Text Routine Mappings
| TCHAR.H routine | _UNICODE & _MBCS not defined | _MBCS defined | _UNICODE defined |
|---|---|---|---|
| _tcsrchr | strrchr | _mbsrchr | wcsrchr |
Requirements
| Routine | Required header | Compatibility |
|---|---|---|
| strrchr | <string.h> | ANSI, Win 98, Win Me, Win NT, Win 2000, Win XP |
| wcsrchr | <string.h> or <wchar.h> | ANSI, Win 98, Win Me, Win NT, Win 2000, Win XP |
| _mbsrchr | <mbstring.h> | Win 98, Win Me, Win NT, Win 2000, Win XP |
For additional compatibility information, see Compatibility in the Introduction.
Libraries
All versions of the C run-time libraries.
Example
For an example of using strrchr, see strchr.
See Also
String Manipulation Routines | strchr | strcspn | _strnicmp | strpbrk | strspn | Run-Time Routines and .NET Framework Equivalents