Commit | Line | Data |
---|---|---|
cb8c26cc TL |
1 | |
2 | Write a program which copies all lines containng | |
3 | the letter 'p' from its input to its output. | |
4 | Compile and test it; then type "ready". | |
5 | #once #create Ref | |
6 | mountain station south orange maplewood millburn short hills | |
7 | new providence murray hill berkeley heights | |
8 | bernardsville far hills peapack gladstone | |
9 | #once #create badin | |
10 | hoboken harrison newark roseville avenue grove street | |
11 | east orange brick church orange highland avenue | |
12 | mountain station south orange maplewood millburn short hills | |
13 | summit chatham madison convent station morristown | |
14 | new providence murray hill berkeley heights | |
15 | gillette stirling millington lyons basking ridge | |
16 | bernardsville far hills peapack gladstone | |
17 | #once cp %s/getline.o . | |
18 | #user | |
19 | a.out <badin >xxx | |
20 | #cmp Ref xxx | |
21 | #succeed | |
22 | /* a way to find lines with 'p' */ | |
23 | \b#include <stdio.h> | |
24 | ||
25 | main() | |
26 | { | |
27 | char line[500]; | |
28 | int k; | |
29 | ||
30 | while (getline(line, 500) > 0) | |
31 | for (k = 0; line[k] != '\0'; k++) | |
32 | if (line[k] == 'p') { | |
33 | printf("%s", line); | |
34 | break; | |
35 | } | |
36 | } | |
37 | #log | |
38 | #next | |
39 | 16.2c 5 | |
40 | 17.1a 10 |