swab(3C) DG/UX 4.30 swab(3C)
NAME
swab - Swap the bytes within each pair of bytes in a string.
SYNOPSIS
char *string1, *string2;
int num;
...
swab(string1, string2, num);
where string1 contains the bytes to be swapped
string2 contains the result of swapping
num is the number of bytes to swap
DESCRIPTION
Use the swab function to swap the bytes within each pair of
bytes in a string. The number of bytes to swap, num, should
be even. If, however, the number is odd, the value (num -
1) is used instead.
RETURNS
The swab function does not return a value.
SEE ALSO
strlen(3c), strcpy(3c).
EXAMPLE
/* Program test for the swab() function */
#include <stdio.h>
#define MAX 80
char string[MAX], *swab();
int length, strlen();
int i = 1;
main(argc, argv)
int argc;
char *argv[];
{
while (i < argc) {
length = strlen(argv[i]);
swab(argv[i], string, length);
printf("'%s' ==> '%.@s'\n",
argv[i], length, string);
i++;
}
}
A call to the program test with
x test Swap these bytes.
Licensed material--property of copyright holder(s) Page 1
swab(3C) DG/UX 4.30 swab(3C)
generates the output
'Swap' ==> 'wSpa'
'these' ==> 'htsee'
'bytes.' ==> 'ybet.s'
Licensed material--property of copyright holder(s) Page 2