How to get digit frequency for numbers 0 to 9 from a string in c
Am supposed to come up with a function to count the frequency of the numbers 0 to 9 in a string submitted by a user. How do I iterate through the string while counting the number of times each digit has occurred, if a digit in this range is not found then am supposed to register 0 for that number and then print out the frequencies separated by spaces. Here is the method I tried so far and got stuck void mysolution(char * m){ //declare our array of integers int arr[10]; for(int i=0;i<=9;i++){ arr[i]=i; } //declare another integer array for freqs int freqs[10]; for(int i=0;i<10;i++){ freqs[i]=0; } for(int t=0;t<strlen(m);t++){ //how do i chck presence of number in string and increment its frequencies } } int main(){ //change s to be read from stdin char s[MAX_SIZE]; fgets(s,MAX_SIZE,stdin); //mysolution(s); }