Reactos
at master 46 lines 1.2 kB view raw
1/*** 2*strnset.c - set first n characters to single character 3* 4* Copyright (c) Microsoft Corporation. All rights reserved. 5* 6*Purpose: 7* defines _strnset() - sets at most the first n characters of a string 8* to a given character. 9* 10*******************************************************************************/ 11 12#include <string.h> 13 14/*** 15*char *_strnset(string, val, count) - set at most count characters to val 16* 17*Purpose: 18* Sets the first count characters of string the character value. 19* If the length of string is less than count, the length of 20* string is used in place of n. 21* 22*Entry: 23* char *string - string to set characters in 24* char val - character to fill with 25* unsigned count - count of characters to fill 26* 27*Exit: 28* returns string, now filled with count copies of val. 29* 30*Exceptions: 31* 32*******************************************************************************/ 33 34char * __cdecl _strnset ( 35 char * string, 36 int val, 37 size_t count 38 ) 39{ 40 char *start = string; 41 42 while (count-- && *string) 43 *string++ = (char)val; 44 45 return(start); 46}