tweak: use else if instead of wrapped else, if
+formatting
This commit is contained in:
parent
926eab1a9b
commit
c3ac29d887
4
src/wc.c
4
src/wc.c
|
@ -8,12 +8,10 @@ int wc(FILE* fp)
|
||||||
while ((c = getc(fp)) != EOF) {
|
while ((c = getc(fp)) != EOF) {
|
||||||
if (c != ' ' && c != '\n' && c != '\t') {
|
if (c != ' ' && c != '\n' && c != '\t') {
|
||||||
word = 1;
|
word = 1;
|
||||||
} else {
|
} else if (word) {
|
||||||
if (word) {
|
|
||||||
num_words++;
|
num_words++;
|
||||||
word = 0;
|
word = 0;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
num_words += word;
|
num_words += word;
|
||||||
printf("%i\n", num_words);
|
printf("%i\n", num_words);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user