ProgrammingHard

struct Grid { int cell[2][2]; }; struct Grid g1 = {{{1, 2}, {3, 4}}}; struct Grid g2 = g1; g2.cell[1][1] = 0; printf("%d", g1.cell[1][1]); What is printed?

  1. A. 0
  2. B. 3
  3. C. 2
  4. D. 4

Correct answer: D. 4

Assignment of a struct copies all its members, including arrays inside it. Only the copy g2 changes.

More C Programming questions

Exams that ask this topic