ProgrammingHard

char s[] = "x=1;y=2"; char *t = strtok(s, "="); printf("%s %zu", t, strlen(s)); What is printed?

  1. A. x 7
  2. B. x=1 7
  3. C. x=1 3
  4. D. x 1

Correct answer: D. x 1

strtok overwrites the delimiter with '\0', so the string is cut at the first token. strlen(s) becomes 1, and the rest of the array is hidden from it.

More C Programming questions

Exams that ask this topic