char *word_breaks = " \n\t";
int slow_wordcount(char *str)
{
int count = 0;
char *s;
s=str;
s+=strspn(s,word_breaks); //Skip leading white space
while(s)
{
s=strpbrk(s,word_breaks); //Find the beginning of the white space
if(s) s+=strspn(s,word_breaks); //Find the end of the white space
count++; //Increment count - Note it starts as 0 not 1
}
return(count);
}
void slow_str_to_ptrarray(char *orgstr, char *ptrarray[])
{
int i=0;
char *s;
s=strtok(orgstr,word_breaks); //Find the first word
while(*s)
{
ptrarray[i]=s; //assign it
i++;
s=strtok(NULL,word_breaks); //Find the rest of the words
}
}
// End of File