Did you know you can highlight text to take a note? x
Figure %: Storing the value 220 into steve

This seems straightforward, and it is. But behind the scenes, there is more going on. As coders, we are able to access the variable steve just by using its name. But how does the computer know where into memory to put the value we store into steve? The answer is that every variable stored in memory has an address associated with it, and the computer keeps track of these addresses. When you tell it to store a value into the variable steve, the computer finds the address at which steve is located, and puts the value into the memory at that location.

Memory Addresses

What does the concept of "addresses" really mean in terms of a computer? What it means is that every piece of the computer's memory is numbered so it can be found easily. A better pictorial representation for memory, as opposed to the blob above is a straight segment of memory, as follows:

Figure %: A pictorial representation of memory

In this figure, each box represents one byte of memory. What are the numbers below each box? Those are addresses. Each number corresponds to one byte; in other words, we can find and access any byte in memory just by knowing its address (remember that a byte is 8 bits. A bit is the smallest unit of storage in a computer, storing either a 0 or a 1).

Let's return to the example from above, and let's say that steve was stored at address 728 in memory and the value 220 was stored into steve:

Figure %: Storing 220 into memory address 728

This figure raises a few questions.

First, why does steve cover bytes 728, 729, 730, and 731? I thought we were just storing it into 728? Not exactly.