Memory Addresses
The memory of a computer can be modeled as a very long array of bytes. Each byte has an address that has the same role as an array subscript. Every variable has an address that is the first of perhaps several byte addresses at which the bits of the variable are stored. Normal variables are known by a name that the compiler translates into an address. The following diagram shows a region of memory as a long tape extending from left to right. The hexadecimal numbers above the tape are memory addresses. For simplicity, we have only shown every fourth byte address:
The bytes of memory have no fixed meaning until the program declares a variable. In the diagram, the program has declared an int
variable named i
, and initialized it to the integer value 12345
. The compiler reserves 4 bytes of storage for the int
variable, which defines this particular storage to hold an integer value...