Bell 32V development
[unix-history] / usr / lib / learn / C / L16.2b
CommitLineData
cb8c26cc
TL
1#print
2Write a program which copies all lines containng
3the letter 'p' from its input to its output.
4Compile and test it; then type "ready".
5#once #create Ref
6mountain station south orange maplewood millburn short hills
7new providence murray hill berkeley heights
8bernardsville far hills peapack gladstone
9#once #create badin
10hoboken harrison newark roseville avenue grove street
11east orange brick church orange highland avenue
12mountain station south orange maplewood millburn short hills
13summit chatham madison convent station morristown
14new providence murray hill berkeley heights
15gillette stirling millington lyons basking ridge
16bernardsville far hills peapack gladstone
17#once cp %s/getline.o .
18#user
19a.out <badin >xxx
20#cmp Ref xxx
21#succeed
22/* a way to find lines with 'p' */
23 \b#include <stdio.h>
24
25main()
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
3916.2c 5
4017.1a 10