#include <stdio.h>
#include <string.h>
int main(void) {
  char tekst[10000], test=0;
  char* word;
  char word_copy[100][100];
  int i=0, lenght=0;
  printf("Type in your text: ");
  fgets(tekst, 10000, stdin);
  lenght=strlen(tekst)-1;
  if(lenght>1000)
  {
    lenght=1000;
  }
  word=strtok(tekst, " ,\".-");
  while( word != NULL)
    {
      word=strtok(NULL, " ,\".-");
      printf("%s ", word);
      i++;
    }
  printf("%d", i);
Hello. What I want to do, is to count words only by using strtok. However, if i type: "example" or -example-, i get the answer "2" instead of "1". For some reason, when the last word is (null), it still triggers the loop, and i++ works... I'm pretty new to programming, so i would aprreciate writing the correct code down aswell.
 
     
    