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 f78b1fd + 988e08b commit a24dc20Copy full SHA for a24dc20
chapter_1/exercise_1_13/histogram.c
@@ -23,9 +23,9 @@ int main(void)
23
// specific index
24
char c;
25
int word_count_index = 0;
26
- while ((c = getchar()) != EOF)
+ while (c = getchar())
27
{
28
- if (c == ' ' || c == '\t' || c == '\n')
+ if (c == ' ' || c == '\t' || c == '\n' || c == EOF)
29
30
if (word_count_index > 0)
31
@@ -43,6 +43,10 @@ int main(void)
43
44
word_count_index = 0;
45
}
46
+ if (c == EOF)
47
+ {
48
+ break;
49
+ }
50
51
else
52
0 commit comments