We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 1506a2a commit a53391bCopy full SHA for a53391b
chapter_1/exercise_1_12/copy_io_nl.c
@@ -2,22 +2,21 @@
2
3
int main()
4
{
5
- char c;
6
- char last_char = -1;
+ int c, prev;
+ prev = EOF;
7
8
while ((c = getchar()) != EOF) {
9
- if((c==' ' || c=='\t' || c=='\n')) {
10
- if(c != last_char) {
+ if (c == ' ' || c == '\t' || c == '\n') {
+ if (prev != ' ' && prev != '\t' && prev != '\n') {
11
putchar('\n');
12
}
13
14
else {
15
putchar(c);
16
17
18
- last_char=c;
+ prev = c;
19
20
21
return 0;
22
23
-
0 commit comments