How to use _swab to swaps each pair of adjacent bytes in C

1 Answer

0 votes
#include <stdio.h>
#include <string.h>

int main()
{
    char from[] = "abcdefg";
    char to[] = "*************";

    _swab(from, to, sizeof(from));

    printf("from: %s\n", from);
    printf("to: %s\n", to);

    return 0;
}




/*
run:

from: abcdefg
to: badcfe

*/

 



answered Apr 11, 2022 by avibootz
...