server-api-bzero

原型

The bzero() function sets the first n bytes of the area starting at s to zero (bytes contain‐ing ‘\0’).

将一段内存内容全清为零 memset((void*)s,0,size_tn);

函数原型
1
2
3
4
5
6
7
8
9
10
11
// s
// 要清零的内存区域
// n
// 要处理清零的字节数
//
// return:
// None
// 没有返回值
//
//
void bzero(void *s, 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;
}