1: static char *sccsid = "@(#)rev.c 4.1 (Berkeley) 10/1/80";
2: #include <stdio.h>
3:
4: /* reverse lines of a file */
5:
6: #define N 256
7: char line[N];
8: FILE *input;
9:
10: main(argc,argv)
11: char **argv;
12: {
13: register i,c;
14: input = stdin;
15: do {
16: if(argc>1) {
17: if((input=fopen(argv[1],"r"))==NULL) {
18: fprintf(stderr,"rev: cannot open %s\n",
19: argv[1]);
20: exit(1);
21: }
22: }
23: for(;;){
24: for(i=0;i<N;i++) {
25: line[i] = c = getc(input);
26: switch(c) {
27: case EOF:
28: goto eof;
29: default:
30: continue;
31: case '\n':
32: break;
33: }
34: break;
35: }
36: while(--i>=0)
37: putc(line[i],stdout);
38: putc('\n',stdout);
39: }
40: eof:
41: fclose(input);
42: argc--;
43: argv++;
44: } while(argc>1);
45: }
Defined functions
main
defined in line
10;
never used
Defined variables
line
defined in line
7; used 2 times
sccsid
defined in line
1;
never used
Defined macros
N
defined in line
6; used 2 times