Exportar (0) Imprimir
Expandir todo
div
eof
Expandir Minimizar

strrchr, wcsrchr, _mbsrchr, _mbsrchr_l

Scan a string for the last occurrence of a character.


char *strrchr(
   const char *str,
   int c 
); // C only
char *strrchr(
   char *str,
   int c 
); // C++ only
const char *strrchr(
   const char *str,
   int c 
); // C++ only
wchar_t *wcsrchr(
   const wchar_t *str,
   wchar_t c 
); // C only
wchar_t *wcsrchr(
   wchar_t *str,
   wchar_t c 
); // C++ only
const wchar_t *wcsrchr(
   const wchar_t *str,
   wchar_t c 
); // C++ only
unsigned char *_mbsrchr(
   const unsigned char *str,
   unsigned int c 
); // C only
unsigned char *_mbsrchr(
   unsigned char *str,
   unsigned int c 
); // C++ only
const unsigned char *_mbsrchr(
   const unsigned char *str,
   unsigned int c 
); // C++ only
unsigned char *_mbsrchr_l(
   unsigned char *str,
   unsigned int c,
   _locale_t locale
); // C++ only
const unsigned char *_mbsrchr_l(
   const unsigned char *str,
   unsigned int c,
   _locale_t locale
); // C++ only

Parameters

str

Null-terminated string to search.

c

Character to be located.

locale

Locale to use.

Returns a pointer to the last occurrence of c in str, or NULL if c is not found.

The strrchr function finds the last occurrence of c (converted to char) in str. 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.

In C, strrchr, wcsrchr and _mbsrchr take a const pointer for the first argument. In C++, two overloads are available. The overload taking a pointer to const returns a pointer to const; the version that takes a pointer to non-const returns a pointer to non-const. The macro _CONST_CORRECT_OVERLOADS is defined if both the const and non-const versions of these functions are available.

_mbsrchr validates its parameters. If str is NULL, the invalid parameter handler is invoked, as described in Parameter Validation. If execution is allowed to continue, errno is set to EINVAL and _mbsrchr returns 0. strrchr and wcsrchr do not validate their parameters. These three functions behave identically otherwise.

The output value is affected by the setting of the LC_CTYPE category setting of the locale; see setlocale for more information. The versions of these functions without the _l suffix use the current locale for this locale-dependent behavior; the versions with the _l suffix are identical except that they use the locale parameter passed in instead.

Generic-Text Routine Mappings
TCHAR.H routine _UNICODE & _MBCS not defined _MBCS defined _UNICODE defined

_tcsrchr

strrchr

_mbsrchr

wcsrchr

n/a

n/a

_mbsrchr_l

n/a

Routine Required header Compatibility

strrchr

<string.h>

ANSI, Windows 95, Windows 98, Windows 98 Second Edition, Windows Millennium Edition, Windows NT 4.0, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003

wcsrchr

<string.h> or <wchar.h>

ANSI, Windows 95, Windows 98, Windows 98 Second Edition, Windows Millennium Edition, Windows NT 4.0, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003

_mbsrchr, _mbsrchr_l

<mbstring.h>

ANSI, Windows 95, Windows 98, Windows 98 Second Edition, Windows Millennium Edition, Windows NT 4.0, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003

For additional compatibility information, see Compatibility in the Introduction.

For an example of using strrchr, see strchr.

Adiciones de comunidad

AGREGAR
Mostrar:
© 2014 Microsoft