Bell 32V development
[unix-history] / usr / lib / learn / C / L15.1b
CommitLineData
cb8c26cc
TL
1#print
2Write a program that reads in lines, and prints each out
3in reverse order (except that the newline should be
4at the end).
5Thus the line
6cat food
7should come out as
8doof tac
9Compile it and run it, then type "ready".
10#once #create Ref1
11This is odd.
12This is even.
13
14#once #create Ref2
15.ddo si sihT
16.neve si sihT
17
18#once cp %s/getline.o .
19#user
20a.out <Ref1 >x1
21#cmp x1 Ref2
22#succeed
23/* one way to do this */
24 \b#include <stdio.h>
25
26main()
27{
28 char line[500];
29 int n;
30
31 while ((n = getline(line, 500)) > 0) {
32 for (n -= 2; n >= 0; n--)
33 putchar(line[n]);
34 putchar('\n');
35 }
36}
37#log
38#next
3917.1a 10
4016.2a 5