I'm a beginner programmer and im trying to solve some exercises and i needed some help with one of them. The exercise goes like this:
We need to input a string of characters , read it and print out the length of each word.
This is what i did
int main()
{
char str[N+1+1];
int i=0;
int pos=0;
int wordlen=0;
int word[60]={0,};
printf("Please enter the string of characters: ");
gets(str);
while(i<strlen(str))
{
    if(!isalpha(str[i]))
    {
        wordlen=0;
        i++;
    }
    if(isalpha(str[i]))
    {
        wordlen++;
        i++;
        pos=i;
    }
    word[pos]=wordlen;
    wordlen=0;;
    i++;
}
for(i=0;i<20;i++)
{
    if(word[i]==0) // here im just trying to find a way to avoid printing 0's but you can ignore it if you want
        {break;}
    else
        printf("%d ",word[i]);
}
  return 0;
}
The problem is that when i try to compile it for example: I input "hi hi hi" its supposed to print 2 2 2 but instead it's printing nothing.
Can i ask for some help?
 
    