HP C/iX Library Reference Manual (30026-90004)

358 Chapter5
HP C/iX Library Function Descriptions
swab
swab
Swaps bytes in an array.
Syntax
void swab (char *
from
, char *
to
, int
nbytes
);
Parameters
from
A pointer to the source array.
to
A pointer to the target array.
nbytes
The number of bytes to copy.
Return Values
None.
Description
This function copies
nbytes
bytes pointed to by
from
to the array pointed to by
to
,
exchanging adjacent even and odd bytes. It is useful for carrying binary data between
byte-swapped and non-byte-swapped machines. The
nbytes
parameter should be even and
non-negative. If
nbytes
is odd and positive, swab() uses
nbytes-1
instead. If
nbytes
is
negative, swab() does nothing.