ProgrammingVery hard

char buf[5] = "abcd"; buf[4] = 'e'; printf("%.5s", buf); What is printed (no terminator is present, which is defined)?

  1. A. abcd
  2. B. abcde\0
  3. C. abcde
  4. D. abcdX

Correct answer: C. abcde

The precision .5 reads exactly five characters, and the array holds five bytes, so nothing past the array is touched.

More C Programming questions

Exams that ask this topic