back
Intro to Using Pointers
Pointers are another way of accessing the information stored in variables. The information contained in a variable is stored in a memory cell; and that memory cell has an address. It is often faster to use data by referring to the data's address than the variable itself.

I know programming is confusing enough as it is, and pointers just seem to add one more layer of confusion on top of the pile. However, it's not that bad once you get the general idea. You see, the whole idea is to use the fastest way to process the data. As you start working with huge programs like 3D games, you need to be able to process as fast as you possibly can. Even with today's programming technology, the user still has to wait once in a while in between segments of a video game, and we know how annoying that can be. Pointers are a way of speeding up the whole process because it is often faster to refer directly to the memory cell addresses.

Use the idea of zip codes as an example. Let's say you wanted to send bulk mail (junk mail) to everyone in your immediate area. By telling the post office the zip code of the area, you could have the junk sent to everyone in that zip code. This would be enormously faster than finding each and every person's name and address. Do you see how a clever addressing scheme can speed things up? That's what pointers are really all about.

The following examples should help clarify the beginning section of chapter 10 in your book.

Here is an example of how it works:

[pointer example #1]

Compare this second example:

[pointer example #2]

This is a revised version of exercise 10-3 in your book (page 188). Copy, compile and execute the code to see how it works:

[exercise 10-3]

Assignment
Verbally explain first to another student and then to me, how a pointer works.

Homework
Read pages 189-192 in Knowlton. Do exercises 10-4 through 10-5.