Поделиться через


_swab

Swaps bytes.

void _swab(
   char *src,
   char *dest,
   int n 
);

Параметры

  • src
    Data to be copied and swapped.

  • dest
    Storage location for swapped data.

  • n
    Number of bytes to be copied and swapped.

Заметки

If n is even, the _swab function copies n bytes from src, swaps each pair of adjacent bytes, and stores the result at dest. If n is odd, _swab copies and swaps the first n-1 bytes of src. _swab is typically used to prepare binary data for transfer to a machine that uses a different byte order.

Требования

Routine

Required header

_swab

<stdlib.h>

For additional compatibility information, see Compatibility in the Introduction.

Пример

// crt_swab.c

#include <stdlib.h>
#include <stdio.h>

char from[] = "BADCFEHGJILKNMPORQTSVUXWZY";
char to[] =   "..........................";

int main()
{
    printf( "Before: %s\n        %s\n\n", from, to );
    _swab( from, to, sizeof( from ) );
    printf( "After:  %s\n        %s\n\n", from, to );
}

Before: BADCFEHGJILKNMPORQTSVUXWZY
        ..........................

After:  BADCFEHGJILKNMPORQTSVUXWZY
        ABCDEFGHIJKLMNOPQRSTUVWXYZ

Эквивалент в .NET Framework

Not applicable. To call the standard C function, use PInvoke. For more information, see Platform Invoke Examples.

См. также

Основные понятия

Buffer Manipulation