Not perfect.
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
void swab(const void *restrict src, void *restrict dst, size_t len);
int main(void)
{
const char *source = "ePllse Csig oo!d"; // len 16
const char *source1 = "hTsii son t "; // len 13
char target[19];
swab(source, target, strlen(source));
printf("swab(%s) becomes (%s)\n", source, target);
swab(source1, target, strlen(source1));
printf("swab(%s) becomes (%s)\n", source1, target);
return 0;
}
void swab(const void *restrict src, void *restrict dst, size_t len)
{
for (int i = 0; i < len; i += 2) {
*((char*)dst+i+1) = *((char*)src+i);
*((char*)dst+i) = *((char*)src+i+1);
}
*((char*)dst+len) = 0;
}