October 2004
Beginner
408 pages
9h 24m
English
Finding out a variable's address is very simple: C provides the address-of operator (&) to do just that. This operator takes the name of a variable and returns the variable's starting address in memory. For now, think of an address as a big number.
If you have a variable defined as int counter, the correct syntax to get its address is &counter.
Our first example uses the address-of operator to show how variables are laid out in the memory of your computer. The five variables shown in Figure 9.1 will be used in the example so you can see for yourself how your particular environment stores the data.
1. | Create a new file or project in your text editor or IDE. |
2. | Type the standard beginning lines ... |
Read now
Unlock full access