ProgrammingModerate

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

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

Correct answer: C. 3

strtok skips runs of delimiters, so the empty field between the two commas gives no token. Only 'a', 'b' and 'c' are returned.

More C Programming questions

Exams that ask this topic