strnset.c
来自「C标准库源代码」· C语言 代码 · 共 48 行
C
48 行
/***
*strnset.c - set first n characters to single character
*
* Copyright (c) 1985-1997, Microsoft Corporation. All rights reserved.
*
*Purpose:
* defines _strnset() - sets at most the first n characters of a string
* to a given character.
*
*******************************************************************************/
#include <cruntime.h>
#include <string.h>
/***
*char *_strnset(string, val, count) - set at most count characters to val
*
*Purpose:
* Sets the first count characters of string the character value.
* If the length of string is less than count, the length of
* string is used in place of n.
*
*Entry:
* char *string - string to set characters in
* char val - character to fill with
* unsigned count - count of characters to fill
*
*Exit:
* returns string, now filled with count copies of val.
*
*Exceptions:
*
*******************************************************************************/
char * __cdecl _strnset (
char * string,
int val,
size_t count
)
{
char *start = string;
while (count-- && *string)
*string++ = (char)val;
return(start);
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?