File:  [CSRG BSD Unix] / 43BSDReno / usr.bin / learn / learnlib / C / L15.1b
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs
Tue Apr 24 16:12:56 2018 UTC (8 years, 1 month ago) by root
Branches: MAIN, BSD
CVS tags: HEAD, BSD43reno
BSD 4.3reno

#print
Write a program that reads in lines, and prints each out
in reverse order (except that the newline should be
at the end).
Thus the line
cat food
should come out as
doof tac
Compile it and run it, then type "ready".
#once #create Ref1
This is odd.
This is even.

#once #create Ref2
.ddo si sihT
.neve si sihT

#once cp %s/getline.o .
#user
a.out <Ref1 >x1
#cmp x1 Ref2
#succeed
/*	one way to do this */
 #include <stdio.h>

main()
{
	char line[500];
	int n;

	while ((n = getline(line, 500)) > 0) {
		for (n -= 2; n >= 0; n--)
			putchar(line[n]);
		putchar('\n');
	}
}
#log
#next
17.1a 10
16.2a 5

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.