COHERENT manpages
This page displays the COHERENT manpage for swab() [Swap a pair of bytes].
List of available manpages
Index
swab() -- General Function (libc) Swap a pair of bytes void swab(src, dest, nb) char *src, *dest; unsigned nb; The ordering of bytes within a word differs from machine to machine. This may cause problems when moving binary data between machines. swab() interchanges each pair of bytes in the array src that is n bytes long, and places the result into the array dest. The length nb should be an even number, or the last byte will not be touched. src and dest may be the same place. Example 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); } See Also byte ordering, dd, canon.h, libc