_strnset, _fstrnset

Description

Initialize characters of a string to a given character.

#include <string.h> Required only for function declarations  

char *_strnset( char *string, int c, size_t count );

char __far * __far _fstrnset( char __far *string, int c, size_t count );

string String to be initialized  
c Character setting  
count Number of characters set  

Remarks

The _strnset and _fstrnset functions set, at most, the first count characters of string to c (converted to char) and return a pointer to the altered string. If count is greater than the length of string, the length of string is used in place of count.

The _fstrnset function is a model-independent (large-model) form of the _strnset function. The behavior and return value of _fstrnset are identical to those of the model-dependent function _strnset, with the exception that all the arguments and return values are far.

Return Value

The return values for these functions are described above.

Compatibility

_strnset

Standards:None

16-Bit:DOS, QWIN, WIN, WIN DLL

32-Bit:DOS32X

_fstrnset

Standards:None

16-Bit:DOS, QWIN, WIN, WIN DLL

32-Bit:None

See Also

strcat, strcmp, strcpy, _strset

Example

/* STRNSET.C */

#include <string.h>

#include <stdio.h>

void main( void )

{

char string[15] = "This is a test";

/* Set not more than 4 characters of string to be *'s */

printf( "Before: %s\n", string );

_strnset( string, '*', 4 );

printf( "After: %s\n", string );

}

Output

Before: This is a test

After: **** is a test