Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint

Pointer Basics

Pointers are variable addresses. Instead of an address such as

1313 Mockingbird Lane
Raven Heights, California 90263

a variable's address refers to a memory location within your computer. As we discussed in Chapter 3, your computer's memory, also known as random access memory (RAM) consists of a sequence of bytes. One megabyte of RAM has exactly 220 (or 1,048,576) bytes of memory, while 8 megabytes of RAM has exactly 8 * 220 = 223 = 8,388,608 bytes of memory. One gigabyte of RAM has exactly 230 bytes = 1,024 megabytes = 1,073,741,824 bytes of memory. And so on.

Every one of those bytes has its own unique address. Computer addresses typically start with 0 and continue up, one at a time, until they reach the highest address. The first byte has an address of 0; the next byte has an address of 1, and so on. Figure 7-3 shows the addressing scheme for a computer with a gigabyte of RAM. A gigabyte is 1,024 megabytes. Notice that the addresses run from 0 (the lowest address) all the way up to 1,073,741,823 (the highest address). The same scheme would hold true for 10 gigabytes, or even 1 terabyte (1,024 gigabytes).


  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint