0

For example it prints '(night' despite tokenizing (), why does this happen?

char* word = strtok(&c, ",.;()");
  while(word!= NULL)
  {
    word = strtok(NULL, ",.;()");
    printf("%s ", &c);
  }
RiRi
  • 11
  • 1

1 Answers1

1

Your code just prints &c on every iteration (whatever that is). You never print word, which is your next token. That's why you never see the results of your tokenization. If you want to see the tokens, you have to print word, not c.

On top of that it is completely unclear why you are applying & operator to your c. If c is a string pointer or a char array, that & there makes no sense at all.

AnT stands with Russia
  • 312,472
  • 42
  • 525
  • 765