The question code lacks a 'return {int value}' statement. I added this missing line, and ended up with the following code:
#include <stdio.h>
/* count characters in input; 2nd version */
int main()
{
double nc;
for (nc =0; getchar() != EOF; ++nc) {
;
}
printf("%.0f\n", nc);
return(0);
}
The above compiled without errors or warnings using:
gcc -Wall -o test test.c
To run it requires that input to the program comes from a file. I made a file named 'junk.txt' with the following content (not including the braces):
[ adddsadsd 33334343434243]
Then I executed the program using the following command:
./test < junk.txt
which generated the output:
25