home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Unix System Administration Handbook 1997 October
/
usah_oct97.iso
/
news
/
cnews.tar
/
libdbz
/
byteflip.c
< prev
next >
Wrap
C/C++ Source or Header
|
1990-05-25
|
614b
|
35 lines
#include <stdio.h>
#define MAXWORD 32
main(argc, argv)
int argc;
char *argv[];
{
register int len;
int inmap[MAXWORD];
int outmap[MAXWORD];
char in[MAXWORD];
char out[MAXWORD];
register int i;
register int a;
a = 1;
len = atoi(argv[a++]);
if (len > MAXWORD)
abort(); /* kind of drastic... */
for (i = 0; i < len; i++)
inmap[i] = atoi(argv[a++]);
if (atoi(argv[a++]) != len)
abort();
for (i = 0; i < len; i++)
outmap[i] = atoi(argv[a++]);
while (fread(in, 1, len, stdin) == len) {
for (i = 0; i < len; i++)
out[outmap[i]] = in[inmap[i]];
fwrite(out, 1, len, stdout);
}
exit(0);
}