swab() — Copy and swap bytes

Standards

Standards / Extensions C or C++ Dependencies

XPG4
XPG4.2
Single UNIX Specification, Version 3

both  

Format

#define _XOPEN_SOURCE
#include <unistd.h>

void swab(const void *__restrict__src, void *__restrict__dest, ssize_t nbytes);

General description

The swab() function copies nbytes bytes, which are pointed to by src to the object pointed to by dest, exchanging adjacent bytes. The nbytes argument should be even. If nbytes is odd, swab() copies and exchanges nbytes-1 bytes and the disposition of the last byte is left unchanged in the target area. If nbytes is zero or negative, no copying is performed.

Returned value

swab() returns no values.

Related information