swab

From RAD Studio
Jump to: navigation, search

Go Up to stdlib.h Index


Header File

stdlib.h

Category

Memory and String Manipulation Routines

Prototype

void swab(char *from, char *to, int nbytes);

Description

Swaps bytes.

swab copies nbytes 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. nbytes 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: %s\n", target);
   return 0;
}

Portability

POSIX Win32 ANSI C ANSI C++

+

+