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.
2 parents 7f68da5 + a8433b9 commit b4ba698Copy full SHA for b4ba698
chapter_1/exercise_1_12/copy_io_nl.c
@@ -1,20 +1,23 @@
1
#include <stdio.h>
2
3
-int main(void)
+int main()
4
{
5
char c;
6
+ char last_char = -1;
7
- while ((c = getchar()) != EOF)
8
- {
9
- if (c == ' ' || c == '\t' || c == '\n')
10
11
- putchar('\n');
+ while ((c = getchar()) != EOF) {
+ if((c==' ' || c=='\t' || c=='\n')) {
+ if(c != last_char) {
+ putchar('\n');
12
+ }
13
}
- else
14
+ else {
15
putchar(c);
16
17
+
18
+ last_char=c;
19
20
21
return 0;
22
23
0 commit comments