首页 > 其他 > 详细

memset函数

时间:2014-12-08 13:55:18      阅读:249      评论:0      收藏:0      [点我收藏+]

memset

接口形式:

void * memset ( void * ptr, int value, size_t num );
用给定的值value填充ptr所指的内存块。
Sets the first num bytes of the block of memory pointed by ptr 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 the unsigned 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函数

原文:http://blog.csdn.net/chenlei0630/article/details/41802497

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!