Swaps bytes.
#include <stdlib.h> | Required only for function declarations |
void _swab( char *src, char *dest, int n );
src | Data to be copied and swapped | |
dest | Storage location for swapped data | |
n | Number of bytes to be copied and swapped |
The _swab function copies n bytes from src, swaps each pair of adjacent bytes, and stores the result at dest. The integer n should be an even number to allow for swapping. The _swab function is typically used to prepare binary data for transfer to a machine that uses a different byte order.
None.
Standards:UNIX
16-Bit:DOS, QWIN, WIN, WIN DLL
32-Bit:DOS32X
Use _swab for compatibility with ANSI naming conventions of non-ANSI functions. Use swab and link with OLDNAMES.LIB for UNIX compatibility.
/* SWAB.C */
#include <stdlib.h>
#include <stdio.h>
char from[] = "BADCFEHGJILKNMPORQTSVUXWZY";
char to[] = "..........................";
void main( void )
{
printf( "Before:\t%s\n\t%s\n\n", from, to );
_swab( from, to, sizeof( from ) );
printf( "After:\t%s\n\t%s\n\n", from, to );
}
Before: BADCFEHGJILKNMPORQTSVUXWZY
..........................
After: BADCFEHGJILKNMPORQTSVUXWZY
ABCDEFGHIJKLMNOPQRSTUVWXYZ