Export (0) Print
Expand All
Expand Minimize
0 out of 1 rated this helpful - Rate this topic

_strset, _wcsset, _mbsset

Set characters of a string to a character.

char *_strset(
   char *string,
   int c 
);
wchar_t *_wcsset(
   wchar_t *string,
   wchar_t c 
);
unsigned char *_mbsset(
   unsigned char *string,
   unsigned int c 
);

Parameters

string
Null-terminated string to be set.
c
Character setting.

Return Value

Returns a pointer to the altered string. No return value is reserved to indicate an error.

Remarks

The _strset function sets all the characters of string to c (converted to char), except the terminating null character. _wcsset and _mbsset are wide-character and multibyte-character versions of _strset. The data types of the arguments and return values vary accordingly. 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.

Generic-Text Routine Mappings

TCHAR.H routine _UNICODE & _MBCS not defined _MBCS defined _UNICODE defined
_tcsset _strset _mbsset _wcsset

Requirements

Routine Required header Compatibility
_strset <string.h> Win 98, Win Me, Win NT, Win 2000, Win XP
_wcsset <string.h> or <wchar.h> Win 98, Win Me, Win NT, Win 2000, Win XP
_mbsset <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

// crt_strset.c

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

int main( void )
{
   char string[] = "Fill the string with something";
   printf( "Before: %s\n", string );
   _strset( string, '*' );
   printf( "After:  %s\n", string );
}

Output

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

See Also

String Manipulation Routines | _mbsnbset | memset | strcat | strcmp | strcpy | _strnset | Run-Time Routines and .NET Framework Equivalents

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.