swab
Swap adjacent bytes
Description
The function swab copieslen bytes from the location referenced by src to the location referenced by dst, swapping adjacent bytes. This is used to copy data from one machine to another with a different byte order.
The argument len must be an even number.
Example:
Example - Swap adjacent bytes
Workings
#include <stdlib.h> #include <stdio.h> #include <string.h> int main() { const char* source="oCedoCsgi srgae t"; char target[18]; swab(source, target, strlen(source)); printf("swab(%s) becomes (%s)",source, target); return 0; }
Solution
Output:
swab(oCedoCsgi srgae t) becomes (CodeCogs is great )
Login
