---
name: "swab"
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/swab/3"
---

# swab(3)

swap adjacent bytes

## NAME

**swab** – swap adjacent bytes

## LIBRARY

Standard C Library (libc, -lc)

## SYNOPSIS

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

*void*\

**swab**(*const void \* restrict src*, *void \* restrict dst*, *ssize\_t len*);

## DESCRIPTION

The function **swab**() copies *len* bytes from the location referenced by *src* to the location referenced by *dst*, swapping adjacent bytes.

The argument *len* must be an even number. If *len* is less than zero, nothing will be done.

## SEE ALSO

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

## HISTORY

A **swab**() function appeared in Version 7 AT&T UNIX.
