ProgrammingVery hard

Which statement about passing a 2D array to a function is correct in C99?

  1. A. The inner dimension can be left empty, as in int m[][], because the compiler infers it
  2. B. The inner dimension must be given (or be a VLA size declared earlier), because the compiler needs the row length to compute addresses
  3. C. A 2D array decays to int ** automatically
  4. D. The function receives a copy of every element, so the size does not matter

Correct answer: B. The inner dimension must be given (or be a VLA size declared earlier), because the compiler needs the row length to compute addresses

C needs the row length to compute offsets, so a parameter like int m[][4] or int m[][n] with n declared earlier is required. int ** is a different type.

More C Programming questions

Exams that ask this topic