ProgrammingHard

char buf[8] = "12"; int n = strlen(buf); printf("%d %d", n, (int)sizeof buf - n); What is printed?

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

Correct answer: C. 2 6

strlen is 2, and the array has 8 bytes, so 8 - 2 = 6 bytes are left after the characters. The output is 2 6.

More C Programming questions

Exams that ask this topic