ECE 1011 - Summer 2003
HOMEWORK #6 (Extra Credit)
(Last Modified: 04 Nov 2010 )
The Extra Credit assignment is to take the finished Maze Game program from Homework #5 (which is described as part of Homework #4.) and:
Modify it so that it uses dynamic memory allocation and/or structures for all relevant variables.
Add the ability to modify the maze and save the present maze to a file (that can be read back into the program).
Remember that multidimensional array indexing only works for arrays declared at compile time - and that's because ALL arrays are inherently one dimensional but if they are declared at compile time then the compiler has enough information to take your multidimensional notation and compute the actual one dimensional index. For dynamically allocated arrays, you have no choice put to either use pointer arithmetic or single dimensional notation (which are really just two slightly different syntaxes for the same thing).
Note that, unlike arrays, structures are passed by value - meaning that the entire contents of the structure is copied to the stack and the function uses that copy and not the actual data. This means that you need to pass pointers to structures if you want to either allow the function to modify the contents of the original structure or if you want to avoid copying large blocks of memory each time a function is called. To get full credit for this assignment, you must pass all structures by reference.