s に含まれる文字 c をカウント

int ch_count(const char *s, int c)
{
   int n;

   for (n = 0; *s; s++)
       n += *s == c;

   return n;
}