for(i=0; i<len; i++)
{
while( !isspace( str[i] ))
{
i++;
}
words++;
}

With this, you can see that words is counted up no matter what. I think if word switched places...