---
name: "bzero"
section: "3"
platform: "freebsd"
package: "base"
version: "16.0-CURRENT-20261027-61c70dc16a79"
release: "FreeBSD 16.0-CURRENT (2026-10-27)"
platforms: ["linux", "freebsd", "macos"]
url: "https://new.carta.tech/bzero"
---

# bzero(3)

write zeroes to memory

## NAME

**bzero**, **explicit\_bzero** – write zeroes to memory

## LIBRARY

Standard C Library (libc, -lc)

## SYNOPSIS

**#include \<strings.h\>**

*void*\

**bzero**(*void \*b*, *size\_t len*);

*void*\

**explicit\_bzero**(*void \*b*, *size\_t len*);

## DESCRIPTION

The **bzero**() function writes *len* zero bytes to the object *b*. If *len* is zero, **bzero**() does nothing.

The **explicit\_bzero**() variant behaves the same, but will not be removed by a compiler's dead store optimization pass, making it useful for clearing sensitive memory such as a password.

## SEE ALSO

[memset(3)](/memset/3.md), [swab(3)](/swab/3.md)

## HISTORY

A **bzero**() function appeared in 4.3BSD. Its prototype existed previously in ⟨string.h⟩ before it was moved to ⟨strings.h⟩ for IEEE Std 1003.1-2001 (“POSIX.1”) compliance.

The **explicit\_bzero**() function first appeared in OpenBSD 5.5 and FreeBSD 11.0.

IEEE Std 1003.1-2008 (“POSIX.1”) removes the specification of **bzero**() and it is marked as LEGACY in IEEE Std 1003.1-2004 (“POSIX.1”). For portability with other systems new programs should use [memset(3)](/memset/3.md).
