Listing 2

main()
{
int ret;
ret = wordcount("one");
printf("Return from word count %d", ret);
}

int wordcount(char *str)
{
int count = 0;
char *s;
s=str;
while(*s && *s==' ')
    s++; //Skip leading spaces
while(s)
   {
   s=strchr(s,' '); //Find the first word break
   while(*s && *s==' ') //Allow for multiple spaces
       s++;
   count++;
   }
return(count);
}
// End of File