bzero()函数

原型:extern void bzero(void *s, int n);

 

用法:#include <string.h>

 

功能:置字节字符串s的前n个字节为零且包括‘’。

 

说明:bzero无返回值,并且使用strings.h头文件,strings.h曾经是posix标准的一部分,但是在POSIX.1-2001标准里面,这些函数被标记为了遗留函数而不推荐使用。在POSIX.1-2008标准里已经没有这些函数了。推荐使用memset替代bzero。

 

举例:

 

// bzero.c

 

/* bzero函数TC和VC中都没有,gcc中提供了 */

 

#include <stdio.h>

 

#include <string.h>

 

int main( void )

 

{

 

struct

 

{

 

int a;

 

char s[5];

 

float f;

 

} tt;

 

char s[20];

 

bzero( &tt, sizeof( tt ) );//等价于memset(&tt,0,sizeof(tt));

 

bzero( s, 20 );//等价于memset(s,0,20);

 

printf( "Initial success." );

 

getchar();

 

return 0;

 

}

原文地址:https://www.cnblogs.com/loanhicks/p/7341692.html