ProgrammingHard

char s[] = "a b,c"; int count = 0; for (char *t = strtok(s, " ,"); t; t = strtok(NULL, " ,")) count++; printf("%d", count); What is printed?

  1. A. 3
  2. B. 2
  3. C. 4
  4. D. 5

Correct answer: A. 3

strtok treats both the space and the comma as separators, so the tokens are a, b and c.

More C Programming questions

Exams that ask this topic