Skip to content

Latest commit

 

History

History
133 lines (105 loc) · 5.65 KB

strset-strset-l-wcsset-wcsset-l-mbsset-mbsset-l.md

File metadata and controls

133 lines (105 loc) · 5.65 KB
description title ms.date api_name api_location api_type topic_type f1_keywords helpviewer_keywords ms.assetid
Learn more about: _strset, _strset_l, _wcsset, _wcsset_l, _mbsset, _mbsset_l
_strset, _strset_l, _wcsset, _wcsset_l, _mbsset, _mbsset_l
4/2/2020
_wcsset
_mbsset
_strset_l
_strset
_wcsset_l
_mbsset_l
_o__mbsset
_o__mbsset_l
_o__wcsset
msvcrt.dll
msvcr80.dll
msvcr90.dll
msvcr100.dll
msvcr100_clr0400.dll
msvcr110.dll
msvcr110_clr0400.dll
msvcr120.dll
msvcr120_clr0400.dll
ucrtbase.dll
api-ms-win-crt-multibyte-l1-1-0.dll
api-ms-win-crt-string-l1-1-0.dll
ntoskrnl.exe
DLLExport
apiref
mbsset
_strset_l
_mbsset
_strset
mbsset_l
strset_l
_wcsset
_ftcsset
wcsset_l
_tcsset_l
_mbsset_l
_wcsset_l
_fstrset
_tcsset
_wcsset_l function
_tcsset function
wcsset_l function
_ftcsset function
characters [C++], setting
_strset function
ftcsset function
strings [C++], setting characters
mbsset function
tcsset_l function
_fstrset function
mbsset_l function
strset_l function
_wcsset function
_mbsset function
_mbsset_l function
tcsset function
_strset_l function
fstrset function
_tcsset_l function
c42ded42-2ed9-4f06-a0a9-247ba305473a

_strset, _strset_l, _wcsset, _wcsset_l, _mbsset, _mbsset_l

Sets characters of a string to a character. More secure versions of these functions are available; see _strset_s, _strset_s_l, _wcsset_s, _wcsset_s_l, _mbsset_s, _mbsset_s_l.

Important

_mbsset and _mbsset_l cannot be used in applications that execute in the Windows Runtime. For more information, see CRT functions not supported in Universal Windows Platform apps.

Syntax

char *_strset(
   char *str,
   int c
);
char *_strset_l(
   char *str,
   int c,
   _locale_t locale
);
wchar_t *_wcsset(
   wchar_t *str,
   wchar_t c
);
wchar_t *_wcsset_l(
   wchar_t *str,
   wchar_t c,
   _locale_t locale
);
unsigned char *_mbsset(
   unsigned char *str,
   unsigned int c
);
unsigned char *_mbsset_l(
   unsigned char *str,
   unsigned int c,
   _locale_t locale
);

Parameters

str
Null-terminated string to be set.

c
Character setting.

locale
Locale to use.

Return value

Returns a pointer to the altered string.

Remarks

The _strset function sets all characters (except the terminating null character) of str to c, converted to char. _wcsset and _mbsset_l are wide-character and multibyte-character versions of _strset, and the data types of the arguments and return values vary accordingly. These functions behave identically otherwise.

_mbsset validates its parameters. If str is a null pointer, the invalid parameter handler is invoked, as described in Parameter validation. If execution is allowed to continue, _mbsset returns NULL and sets errno to EINVAL. _strset and _wcsset don't validate their parameters.

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 are identical, except that the ones that don't have the _l suffix use the current locale and the ones that do have the _l suffix instead use the locale parameter that's passed in. For more information, see Locale.

Important

These functions might be vulnerable to buffer overrun threats. Buffer overruns can be used for system attacks because they can cause an unwarranted elevation of privilege. For more information, see Avoiding buffer overruns.

By default, this function's global state is scoped to the application. To change this behavior, see Global state in the CRT.

Generic-text routine mappings

TCHAR.H routine _UNICODE and _MBCS not defined _MBCS defined _UNICODE defined
_tcsset _strset _mbsset _wcsset
_tcsset_l _strset_l _mbsset_l _wcsset_l

Requirements

Routine Required header
_strset <string.h>
_strset_l <tchar.h>
_wcsset <string.h> or <wchar.h>
_wcsset_l <tchar.h>
_mbsset, _mbsset_l <mbstring.h>

For more compatibility information, see Compatibility.

Example

// crt_strset.c
// compile with: /W3

#include <string.h>
#include <stdio.h>

int main( void )
{
   char string[] = "Fill the string with something.";
   printf( "Before: %s\n", string );
   _strset( string, '*' ); // C4996
   // Note: _strset is deprecated; consider using _strset_s instead
   printf( "After:  %s\n", string );
}
Before: Fill the string with something.
After:  *******************************

See also

String manipulation
Locale
Interpretation of multibyte-character sequences
_mbsnbset, _mbsnbset_l
memset, wmemset
strcat, wcscat, _mbscat
strcmp, wcscmp, _mbscmp
strcpy, wcscpy, _mbscpy
_strnset, _strnset_l, _wcsnset, _wcsnset_l, _mbsnset, _mbsnset_l