It was mentioned in Chapter 6 how variables and constants are data, and data is stored in a computer's memory much like letters are slotted into mailboxes or like files are arranged in the drawers of a filing cabinet. Each slot or area of memory has a specific and unique address called a memory address. As a program is executed it is allocated a finite pool of memory by the operating system to store whatever variable and constant data it declares. Since data varies, the amount of memory needed to store, say, an integer variable differs from the amount needed to store a Boolean. Regardless, each of them still has a unique location in memory (their memory address). The memory size in bytes of any variable or data type can be found out by using the sizeof function, as shown below:
int size_of_integer = sizeof (int); int size_of_boolean = sizeof (bool);
Functions are examined in Chapter 9.
Generally, when a programmer references a variable or constant, it is by using the variable or constant name, such as "int Number"-here, Number is the variable name. However, though the importance might not yet be apparent, it is sometimes useful to know and use the actual memory address of a variable or constant. For this reason, we must now explore pointers.