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 545e73d commit 98981caCopy full SHA for 98981ca
Ch1_Tutorial_Introduction/charcount.c
@@ -14,10 +14,12 @@ int main()
14
}
15
16
while ( ( c = getchar() ) != EOF){
17
- if ( c >= '0' // if the char is a digit
+ if ( c >= '0' // if the char is a digit
18
&& c <= '9'){
19
- ++ndigit[c-'0']; // increment the digit counter
20
- }
+ ++ndigit[c-'0']; // increment the digit counter
+ } // `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
23
else if ( c == ' '
24
|| c == '\n'
25
|| c == '\t'){
0 commit comments