I want to compare the integers in a string with integers (0-9) and I wrote this -

```
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>

int main() {
  char num[100];
  int count = 0;
  scanf("%s", num);
  int len = strlen(num);
  for (int i = 0; i <= 9; i++)
  {
    for (int j = 0; j <= len; j++)
    {
      if (i == (num[j] - '0'))
      {
        count++;
      }
    }
    printf("%d ", count);
    count = 0;
  }
  return 0;
}

```

No problems with this (works in most cases but it is failing in few cases). So can you please give me alternate and best idea to do this?
Thanks in advance

Complete pic -
[![Pic of problem statement with working cases](https://i.stack.imgur.com/x9GY8.jpg)](https://i.stack.imgur.com/x9GY8.jpg)