tweak: use else if instead of wrapped else, if

+formatting
This commit is contained in:
NunoSempere 2023-09-15 12:19:40 +03:00
parent 926eab1a9b
commit c3ac29d887
4 changed files with 15 additions and 17 deletions

BIN
src/wc

Binary file not shown.

View File

@ -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);