¿Le resultó útil esta página?
Sus comentarios sobre este contenido son muy importantes. Háganos saber su opinión.
¿Tiene comentarios adicionales?
Caracteres restantes: 1500
_strset, _strset_l, _wcsset, _wcsset_l, _mbsset, _mbsset_l
div
eof
Collapse the table of content
Expand the table of content

_strset, _strset_l, _wcsset, _wcsset_l, _mbsset, _mbsset_l

Set characters of a string to a character. These functions are deprecated because more secure versions are available; see _strset_s, _strset_s_l, _wcsset_s, _wcsset_s_l, _mbsset_s, _mbsset_s_l.


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.

Returns a pointer to the altered string.

The _strset function sets all the characters of str to c (converted to char), except the terminating null character. _wcsset and _mbsset_l are wide-character and multibyte-character versions of _strset. 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 do not validate their parameters.

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.

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.

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

_tcsset

_strset

_mbsset

_wcsset

_tcsset_l

_strset_l

_mbsset_l

_wcsset_l

Routine Required header Compatibility

_strset

<string.h>

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

_strset_l

<tchar.h>

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

_wcsset

<string.h> or <wchar.h>

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

_wcsset_l

<tchar.h>

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

_mbsset, _mbsset_l

<mbstring.h>

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.

// crt_strset.c
// compile with: /W1

#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 );
}

Output

Before: Fill the string with something.
After:  *******************************

Not applicable. To call the standard C function, use PInvoke. For more information, see Platform Invoke Examples.

Adiciones de comunidad

AGREGAR
Mostrar:
© 2015 Microsoft