1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
#include "common.h" #include <unistd.h> int main(int argc, char** argv) { char src[8] = "ABCDEFG"; char dst[8] = {0}; /* Positive case: normal swab works */ swab(src, dst, 6); puts(dst); /* Negative n: POSIX says swab does nothing, must NOT trap */ swab(src, dst, -1); swab(src, dst, -100); puts(dst); return ret; }