Skip to content

Commit 69f5fe4

Browse files
authored
Merge pull request #52 from pinguxx28/main
shortened exercise 1-12
2 parents e5feae0 + 93bef39 commit 69f5fe4

File tree

1 file changed

+20
-27
lines changed

1 file changed

+20
-27
lines changed

chapter_1/exercise_1_12/copy_io_nl.c

Lines changed: 20 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,20 @@
1-
#include <stdio.h>
2-
3-
#define OUT 0
4-
#define IN 1
5-
6-
int main(void)
7-
{
8-
char c;
9-
int state;
10-
11-
state = OUT;
12-
while ((c = getchar()) != EOF)
13-
{
14-
if (c != ' ' && c != '\t' && c != '\n')
15-
{
16-
putchar(c);
17-
state = IN;
18-
}
19-
else if (state)
20-
{
21-
putchar('\n');
22-
state = OUT;
23-
}
24-
}
25-
26-
return 0;
27-
}
1+
#include <stdio.h>
2+
3+
int main(void)
4+
{
5+
char c;
6+
7+
while ((c = getchar()) != EOF)
8+
{
9+
if (c == ' ' || c == '\t' || c == '\n')
10+
{
11+
putchar('\n');
12+
}
13+
else
14+
{
15+
putchar(c);
16+
}
17+
}
18+
19+
return 0;
20+
}

0 commit comments

Comments
 (0)