_mbsnbset

unsigned char *_mbsnbset( unsigned char *string, unsigned int c, size_t count );

Routine Required Header Compatibility
_mbsnbset <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

_mbsnbset returns a pointer to the altered string.

Parameters

string

String to be altered

c

Single-byte or multibyte character setting

count

Number of bytes to be set

Remarks

The _mbsnbset function sets, at most, the first count bytes of string to c. If count is greater than the length of string, the length of string is used instead of count. If c is a multibyte character and cannot be set entirely into the last byte specified by count, then the last byte will be padded with a blank character. _mbsnbset does not place a terminating null at the end of string.

_mbsnbset is similar to _mbsnset, except that it sets count bytes rather than count characters of c.

Generic-Text Routine Mappings

TCHAR.H Routine _UNICODE & _MBCS Not Defined _MBCS Defined _UNICODE Defined
_tcsnset _strnset _mbsnbset _wcsnset

Example

/* MBSNBSET.C */

#include <mbstring.h>
#include <stdio.h>

void main( void )
{
   char string[15] = "This is a test";
   /* Set not more than 4 bytes of string to be *'s */
   printf( "Before: %s\n", string );
   _mbsnbset( string, '*', 4 );
   printf( "After:  %s\n", string );
}

Output

Before: This is a test
After:  **** is a test

String Manipulation Routines

See Also   _mbsnbcat, _mbsnset, _mbsset