Given a string consisting of alphabets and digits, find the frequency of each digit in the given string
问题 Please tell me whats wrong in code the output is 00000000. I know there is some mistake but cant find it. #include <stdio.h> #include <string.h> int main() { int c=0; char s[100]; fgets(s, 100, stdin); printf("%s", s); for(int i=0;i<=9;i++) { for(int j=0;j<strlen(s);j++) { if(s[j]==i){ c++; } } printf("%d", c); } return 0; } 回答1: Firstly, you are comparing a character with a int. Have a look at Char to int conversion in C for a solution. Then, I would remember you that "0" is index 48 in