ProgrammingModerate

char s[8] = "ab"; strncat(s, "cdefgh", 2); printf("%zu", strlen(s)); What is printed?

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

Correct answer: C. 4

strncat appends the first two characters, cd, giving abcd with length 4. The buffer has room for it.

More C Programming questions

Exams that ask this topic