ProgrammingVery hard

printf("%zu", strcspn("aXbYc", "XY") + strspn(" 42ab", " 0123456789")); What is printed?

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

Correct answer: B. 5

strcspn counts the leading characters outside the second set, which is 1 here (it stops at 'X'). strspn counts the leading characters inside the set, which is 4 for the two spaces, '4' and '2'. 1 + 4 = 5.

More C Programming questions

Exams that ask this topic