|
|
DT249-1 Programming and Algorithms
Weeks 06 and 07
Learning Outcomes:
Upon completion of this class, you should be able to:
- Print out the memory address of a variable.
- Create a pointer to a variable.
- Use pointers instead of arrays.
- Dynamically allocate memory at runtime.
- Describe some of the important uses of pointers in programming.
Tasks
|
1. |
Complete the tasks from
week 5. |
|
2. |
Download the
code for this week's notes. Go
through all the code, compiling and running each program separately.
If you have any problems, ask the lab supervisor for help, or take a
note of the problem and we can discuss it in next week's class.
The code is bundled into a ZIP file. This is a compressed file which
contains all the separate source code files. To open this file and
extract the contents, you can use the WinZip tool which is available
in the lab, and is available for free download
here.
Make sure to put all your code into a folder named week_6_7
in your programming folder on your u: drive.
|
|
3. |
Rewrite the programs from last
week so that they take advantage of the use of pointers and dynamic
memory allocation. Use pointer increment instead of array
subscripting where possible. |
Further Reading
Chapters 8, 9 and 10 of Paul Kelly book
|