ProgrammingModerate

struct Entry { char key[4]; int count; }; struct Entry e[2] = {{"ab", 1}, {"cd", 2}}; printf("%s %d", e[1].key, e[1].count); What is printed?

  1. A. ab 2
  2. B. cd 1
  3. C. c 2
  4. D. cd 2

Correct answer: D. cd 2

e[1] is the second struct, initialised with key "cd" (which fits in char[4] with its terminator) and count 2, so it prints cd 2. ab 2 and cd 1 mix the fields of e[0] and e[1].

More C Programming questions

Exams that ask this topic