首页 > 代码库 > memset函数
memset函数
memset
接口形式:
void * memset ( void * ptr, int value, size_t num );
用给定的值value填充ptr所指的内存块。
Sets the first num bytes of the block of memory pointed byptr to the specified value (interpreted as an unsigned char).Parameters
- ptr
- Pointer to the block of memory to fill.
- value
- Value to be set. The value is passed as an int, but the function fills the block of memory using theunsigned char conversion of this value.
- num
- Number of bytes to be set to the value.
size_t is an unsigned integral type.
Return Value
ptr is returned.例子:
/* memset example */ #include <stdio.h> #include <string.h> int main () { char str[] = "almost every programmer should know memset!"; memset (str,'-',6); puts (str); return 0; }
output:
------ every programmer should know memset!
memset函数
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。