|
|
1.1 ! root 1: #print ! 2: Write a program that reads in lines one at a time, ! 3: and prints them out if their length (including ! 4: the newline) is odd. ! 5: You can use the function getline if you like; the object ! 6: file is in getline.o. ! 7: Compile and run it, then type "ready". ! 8: #once #create Ref1 ! 9: this line contains an odd number of letters! ! 10: this line, however, contains an even number of letters! ! 11: #once #create Ref2 ! 12: this line contains an odd number of letters! ! 13: #once cp %s/getline.o . ! 14: #user ! 15: a.out <Ref1 >x1 ! 16: #cmp x1 Ref2 ! 17: #succeed ! 18: /* It's certainly easiest with getline: */ ! 19: ! 20: #include <stdio.h> ! 21: ! 22: main() ! 23: { ! 24: char line[500]; ! 25: int n; ! 26: ! 27: while ((n = getline(line, 500)) > 0) ! 28: if (n % 2 == 1) ! 29: printf("%s", line); ! 30: } ! 31: #log ! 32: #next ! 33: 15.1b 10
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.