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 85067db commit 3fb4576Copy full SHA for 3fb4576
chapter_2/exercise_2_02/loop.c
@@ -19,22 +19,11 @@ int main(void)
19
{
20
char c = getchar();
21
22
- if (i >= (MAXLINE - 1))
+ if (i >= (MAXLINE - 1) || c == '\n' || c == EOF)
23
24
loop = 0;
25
break;
26
}
27
- else if (c == '\n')
28
- {
29
- loop = 0;
30
- break;
31
- }
32
- else if (c == EOF)
33
34
35
36
37
-
38
s[i++] = c;
39
40
0 commit comments