1SWAB(3) Linux Programmer's Manual SWAB(3)
2
3
4
6 swab - swap adjacent bytes
7
9 #define _XOPEN_SOURCE /* See feature_test_macros(7) */
10 #include <unistd.h>
11
12 void swab(const void *from, void *to, ssize_t n);
13
15 The swab() function copies n bytes from the array pointed to by from to
16 the array pointed to by to, exchanging adjacent even and odd bytes.
17 This function is used to exchange data between machines that have dif‐
18 ferent low/high byte ordering.
19
20 This function does nothing when n is negative. When n is positive and
21 odd, it handles n-1 bytes as above, and does something unspecified with
22 the last byte. (In other words, n should be even.)
23
25 The swab() function returns no value.
26
28 For an explanation of the terms used in this section, see
29 attributes(7).
30
31 ┌──────────┬───────────────┬─────────┐
32 │Interface │ Attribute │ Value │
33 ├──────────┼───────────────┼─────────┤
34 │swab() │ Thread safety │ MT-Safe │
35 └──────────┴───────────────┴─────────┘
37 POSIX.1-2001, POSIX.1-2008, SVr4, 4.3BSD.
38
40 bstring(3)
41
43 This page is part of release 4.15 of the Linux man-pages project. A
44 description of the project, information about reporting bugs, and the
45 latest version of this page, can be found at
46 https://www.kernel.org/doc/man-pages/.
47
48
49
50 2015-08-08 SWAB(3)