Swab (programming)
From Wikipedia, the free encyclopedia
- The correct title of this article is swab (programming). The initial letter is shown capitalized due to technical restrictions.
swab is a function in the C programming language that swaps the contents of two areas of bytes in the memory. As far as traceable, "swab" is a contraction of "swap byte". It is not a standard ISO C library function, so its use is not portable.
The swab()
function is useful for preparing blocks of data for further processing, in situations where the data blocks have been sent through a network arranged in network byte order, and must be rearranged into native byte order (or vice versa). This deals specifically with data blocks that are composed of 2-byte (16-bit) words that must be rearranged so that they have the proper endianness appropriate for the local system.