swab

Copies a specified number of bytes from a source buffer to a destination buffer, swapping every pair of bytes.

Library:LibC
Classification:Other
Service:Characters and Strings

Syntax

  #include <string.h> 
   
  void swab (
     const void   *src, 
     void         *dst, 
     size_t        n); 
  

Parameters

src

(IN) Points to the string to be transformed.

dst

(OUT) Points to the array into which to place the transformed characters.

n

(IN) Specifies the number of bytes to swap.

Remarks

The swab function copies n bytes (which should be even) from src to dst swapping every pair of bytes. This is useful for preparing binary data to be transferred to another machine that has a different byte ordering.

If the number of bytes is odd, the disposition of the last byte is unspecified.