The strstr function returns a pointer to the first occurrence of strSearch in str. The search does not include terminating null characters. wcsstr and _mbsstr are wide-character and multibyte-character versions of strstr. The arguments and return value of wcsstr are wide-character strings; those of _mbsstr are multibyte-character strings. _mbsstr validates its parameters. If str or strSearch is NULL, the invalid parameter handler is invoked, as described in Parameter Validation . If execution is allowed to continue, _mbsstr sets errno to EINVAL and returns 0. strstr and wcsstr do not validate their parameters. These three functions behave identically otherwise.
Security Note: |
|---|
These functions incur a potential threat brought about by a buffer overrun problem. Buffer overrun problems are a frequent method of system attack, resulting in an unwarranted elevation of privilege. For more information, see
Avoiding Buffer Overruns.
|
In C, these functions 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. If you require the non-const behavior for both C++ overloads, define the symbol _CONST_RETURN.
The output value is affected by the setting of the LC_CTYPE category setting of the locale; for more information, see setlocale. 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. For more information, see Locale.
Generic-Text Routine Mappings
TCHAR.H routine
|
_UNICODE & _MBCS not defined
|
_MBCS defined
|
_UNICODE defined
|
|---|
_tcsstr
|
strstr
|
_mbsstr
|
wcsstr
|
n/a
|
n/a
|
_mbsstr_l
|
n/a
|