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 48bf486 commit f5d8768Copy full SHA for f5d8768
Ch1_Tutorial_Introduction/countchar.c
@@ -2,11 +2,10 @@
2
3
// count characters in input
4
int main(){
5
- long nc = 0; //store the character count as a long int, init it as 0
+ double nc; //store the character count as a double
6
7
- while (getchar() != EOF) // while the user hasn't entered an EOF
8
- {
9
- ++nc; // increment the character count
10
- }
11
- printf("%ld\n",nc); // %ld tells printf we are printing a long int
+ for (nc = 0; getchar != EOF; ++nc) //weird for loop that kinda goes forever?
+ ; //do nothing within the loop
+ //isolated semicolon to indicate nothing
+ printf("%.0f\n", nc);
12
}
0 commit comments