Share via


_strset, _wcsset, _mbsset

Set characters of a string to a character.

char*_strset(char*string,intc**);**

wchar_t*_wcsset(wchar_t*string,wchar_tc**);**

unsignedchar*_mbsset(unsignedchar*string,unsignedintc**);**

Routine Required Header Compatibility
_strset <string.h> Win 95, Win NT
_wcsset <string.h> or <wchar.h> Win 95, Win NT
_mbsset <mbstring.h> Win 95, Win NT

For additional compatibility information, see Compatibility in the Introduction.

Libraries

LIBC.LIB Single thread static library, retail version
LIBCMT.LIB Multithread static library, retail version
MSVCRT.LIB Import library for MSVCRT.DLL, retail version

Return Value

Each of these functions returns a pointer to the altered string. No return value is reserved to indicate an error.

Parameters

string

Null-terminated string to be set

c

Character setting

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.

Generic-Text Routine Mappings

TCHAR.H Routine _UNICODE & _MBCS Not Defined _MBCS Defined _UNICODE Defined
_tcsset _strset _mbsset _wcsset

Example

/* STRSET.C */

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

void 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:  ******************************

String Manipulation Routines

See Also   _mbsnbset, memset, strcat, strcmp, strcpy, _strnset