RAD Studio |  |

swab

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

Copy Code

    #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++
+ | + |  |

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!