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 |
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.
The return values for these functions are described above.
_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
strcat, strcmp, strcpy, _strset
/* 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 );
}
Before: This is a test
After: **** is a test