在线编译器 C

#include <stdio.h> int main() { char c; int count_digit=0,; do{ scanf("%c",&c); if(c>='0'&&c<='9'){ count_digit++; int digit=c-'0'; } }while(c!='.'); printf("%d",count_digit); return 0; }
This program reads characters from input one by one until it encounters a period ('.'), and counts how many of those characters are digits (0-9). It then prints the total count of digits.

- There is a syntax error on the line `int count_digit=0,;` — the comma before the semicolon is not allowed. Remove the extra comma.
- The variable `digit` is declared inside the `if` block but never used. This is not an error, but it is unnecessary code that can be removed.