#include<stdio.h>

int char_count(char c, char *str);

int main(int argc, char * argv[])
{
  char default_str[] = "Jackson, Mississippi";
  char * str;

  if (argc > 1) 
    str = argv[1]; 
  else
    str = default_str;
  printf("Your input String is:  %s\n\n", str);

  printf("Counting occurrences of \'s\' in string %s\n", str);
  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;
};
