Skip to content

Commit 98981ca

Browse files
committed
added comments
1 parent 545e73d commit 98981ca

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

Ch1_Tutorial_Introduction/charcount.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,12 @@ int main()
1414
}
1515

1616
while ( ( c = getchar() ) != EOF){
17-
if ( c >= '0' // if the char is a digit
17+
if ( c >= '0' // if the char is a digit
1818
&& c <= '9'){
19-
++ndigit[c-'0']; // increment the digit counter
20-
}
19+
++ndigit[c-'0']; // increment the digit counter
20+
} // `c-'0'` works because chars are small ints
21+
// so the expression is really evaluating an integer representation
22+
// of two characters, but is ultimately about ints
2123
else if ( c == ' '
2224
|| c == '\n'
2325
|| c == '\t'){

0 commit comments

Comments
 (0)