ProgrammingModerate

struct S { int id; int v; }; struct S a[4] = {{1,9},{2,8},{3,7},{4,6}}; struct S b[4]; memcpy(b, a, sizeof a); b[0].v = 0; printf("%d %d", a[0].v, b[0].v); What is printed?

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

Correct answer: C. 9 0

memcpy copies the whole block, so b is independent of a. Changing b[0].v does not affect a[0].v.

More C Programming questions

Exams that ask this topic