In This Chapter
Using two types of memory: the stack and heap
Accessing variable addresses through pointers
Creating variables on the heap by using the
Taking pointers as parameters and returning pointers
Modifying variables the easy way
Where do you live? Don't say it out loud because thousands of people are reading this book, and you don't want them all to know. So just think about your address. Most places have some sort of address so the mail service will know where to deliver your packages and the cable guy can show up sometime between now and 5:00 next Thursday. (So make sure that you're there.)
Other things have addresses too. For example, a big corporation in an office building likely has all its cubes numbered. And offices in buildings usually have numbers; and apartments normally have numbers, too.
Now suppose someone named Sam works in office number 180. Last week, however, Sam got booted out the door for spending too much time surfing the Web. Now Sally gets first dibs on office number 180, even though she's not taking over Sam's position. Sam moved out; Sally moved in. Same office — different person staying there.
The computer's memory works similarly. Every little part of the computer's memory is associated with a number that represents its location, or address. In this chapter, we show you that after you determine the address of a variable stored in memory, you can do powerful things with it, which gives you the ...