码迷,mamicode.com
首页 > 其他好文 > 详细

memset函数

时间:2014-12-08 13:56:27      阅读:194      评论:0      收藏:0      [点我收藏+]

标签:c++   memset   

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函数

标签:c++   memset   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!