swab
raw OCR
Swaps bytes.
Defined in header <stdlib.h>
Syntax
#include <stdlib.h>
void swab(char *from, char *to,int nhytes);
Portability
| DOS | UNIX | Windows | ANSI C | C++ only |
|---|---|---|---|---|
| ■ | ■ | ■ |
Remarks
swab copies nhytes bytes from the from string to the to string. Adjacent even- and odd-byte positions are swapped. This is useful for moving data from one machine to another machine with a different byte order, nhytes should be even.
Return value
None.
Example
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
char source [15] = "rFna koBlrna d";
char target[15];
int main(void)
{
swab(source, target, strlen(source) );
printf{"This is target: ls\n", target);
return 0;
Differences from modern implementations
Nothing recorded yet.
Modern references
These are search links, not yet checked by hand.
Stable link: /3.1/stdlib.h/swab/
· short form /3.1/swab/