sswwaabb() -- General Function (libc)

Swap a pair of bytes
vvooiidd sswwaabb(_s_r_c, _d_e_s_t, _n_b) cchhaarr *_s_r_c, *_d_e_s_t; uunnssiiggnneedd _n_b;

The ordering of bytes within a  word differs from machine to machine.  This
may  cause  problems  when moving  binary  data  between machines.   sswwaabb()
interchanges each pair of bytes in  the array _s_r_c that is _n bytes long, and
places the  result into  the array  _d_e_s_t. The length  _n_b should be  an even
number, or the last byte will not be touched.  _s_r_c and _d_e_s_t may be the same
place.

_E_x_a_m_p_l_e
This example prompts for an integer; it then prints the integer both as you
entered it, and as it appears with its bytes swapped.

#include <stdio.h>

main()
{
    int word;

    printf("Enter an integer: \n");
    scanf("%d", &word);
    printf("The word is 0x%x\n", word);
    swab(&word, &word, 2);
    printf("The word with bytes swapped is 0x%x\n", word);
}

_S_e_e _A_l_s_o
bbyyttee oorrddeerriinngg, dddd, ccaannoonn.hh, lliibbcc
