1 /*- 2 * Copyright (c) 1987 The Regents of the University of California. 3 * All rights reserved. 4 * 5 * %sccs.include.redist.c% 6 */ 7 8 #ifndef lint 9 char copyright[] = 10 "@(#) Copyright (c) 1987 The Regents of the University of California.\n\ 11 All rights reserved.\n"; 12 #endif /* not lint */ 13 14 #ifndef lint 15 static char sccsid[] = "@(#)rev.c 4.5 (Berkeley) 07/17/91"; 16 #endif /* not lint */ 17 18 #include <stdio.h> 19 20 main(argc, argv) 21 int argc; 22 char **argv; 23 { 24 register char *t, *bp; 25 char buf[BUFSIZ]; 26 27 bp = buf; 28 do { 29 if (argc > 1 && !freopen(*++argv, "r", stdin)) { 30 fprintf(stderr, "rev: cannot open %s.\n", *argv); 31 exit(1); 32 } 33 while (fgets(bp, sizeof(buf), stdin)) { 34 for (t = bp; *t; ++t); 35 if (*--t == '\n') 36 --t; 37 for (; t >= bp; --t) 38 putchar(*t); 39 putchar('\n'); 40 } 41 } while(--argc > 1); 42 exit(0); 43 } 44