#include<stdio.h>
int countchar(char *p, char);
main()
{
   char str[]="hello world";
   char ch = ' ';
   printf("count = %d\n", countchar(str, ch));   
   system("pause");      
}
int countchar(char *p, char c)
{
    int counter=0;    
    while(*p != '\0')
    {
       if(*p == c)
          counter++;    
       p++;         
    }
    return counter;
}
