ProgrammingHardProduct company OA

What is printed?

What is printed?
const char *s = "  42, 17";
printf("%zu %zu", strspn(s, " "), strcspn(s, ","));
  1. A. 2 4
  2. B. 3 4
  3. C. 1 4
  4. D. 2 5

Correct answer: A. 2 4

strspn returns the length of the leading run made only of the given characters: two spaces. strcspn returns the length of the leading run that contains none of them: " 42" before the comma, 4 characters. '5' counts up to and including the comma.

More C Programming questions

Exams that ask this topic