ProgrammingHard

char buf[3] = {'a', 'b', 'c'}; printf("%.2s", buf); What is printed?

  1. A. abc
  2. B. a
  3. C. ab
  4. D. ba

Correct answer: C. ab

The precision .2 limits the output to two characters, so the array's missing terminator is never reached.

More C Programming questions

Exams that ask this topic