#include<stdio.h>

#define BUFLEN 256

int char_count(char c, char *str);

int main(int argc, char * argv[])
{
  char *str=0x0, 
        str2[BUFLEN] = "Jackson, Mississippi";

  printf("Counting occurrences of \'s\' in string %s\n", str2);
  int count = char_count('s',str);
  printf("Count: %d\n",count);

  return 0;
}

/* returns number of times character c occurs in str */
int char_count(char c, char *str)
{
  int count = 0;
  char * iter = str;
  while( *iter != '\0')
  {
    if(( *iter==c ))
      count++; 
    iter++;
  }
  return count;
};
