BSD 4_3 development
[unix-history] / usr / src / usr.lib / learn / C / L5.1c
CommitLineData
2e8921b7
C
1#print
2(Section 1.5)
3Write a program which reads one character from
4its input; if that character is ? it prints "yes",
5otherwise it prints "no".
6Compile it, test it, and then type ready.
7#once #create Ref1
8? is here
9#once #create Ref2
10no ? at beginning
11#user
12a.out <Ref1 >test1
13a.out <Ref2 >test2
14grep yes test1 >/dev/null || grep no test2 >/dev/null
15#succeed
16This is one possible solution
17
18main()
19{
20 if (getchar() == '?')
21 printf("yes\n");
22 else
23 printf("no\n");
24}
25
26The indenting and general formatting of C programs
27should be done so you make the structure clear,
28like the code above.
29#log
30#next
315.1d 10