Answers/Solutions to Exercises in Chapter 7, Exercise 1

E1: We discussed static two-dimensional arrays and their row-major storing and the implementation of two-dimensional dynamic
arrays. They both use the same "syntax" for access --- e.g. x[2][3] --- how is it possible given the totally different
storage methods?

A1: The compiler determines from the context --- if x is defined as a pointer, x[2][3] is translated to *(*(x+2)+3), while if x is defined as a two-dimensional array, x[2][3] is replaced by the row-major access formula: *(x+2*row-size+3).

Back to Answers/Solutions Index                          Back to Answers/Solutions for Chapter 7 Index