server-api-memset

原型

The memset() function fills the first n bytes of the memory area pointed to by s with the con‐stant byte c

将参数s所指的内存区域前n个字节以参数c填入

函数原型
1
2
3
4
5
6
7
8
9
10
11
12
13
// s
// 要填入值的内存区域
// c
// 要填入内存的值
// n
// 要处理填入的字节数
//
// return:
// The memset() function returns a pointer to the memory area s.
// 返回指向s内存区域的指针
//
//
void *memset(void *s, int c, size_t n);

使用参考

简单的清理处理
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#include <string.h>
#include <strings.h>
#include <stdio.h>

int main()
{
char s[30];
memset (s,'A',sizeof(s));
s[30]='\0';
printf("memset value: %s\n",s);

bzero(s, sizeof(s));
printf("bzero value:%s\n",s);

return 0;
}