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