memset

来源:互联网 发布:tengine nginx 对比 编辑:程序博客网 时间:2024/05/14 17:33
function
<cstring>

memset

void * memset ( void * ptr, int value, size_t num );
Fill block of memory
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.

Example

1234567891011
/* 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!

See also

0 0
原创粉丝点击