Computer Science 1037A/B Lecture Notes - Lecture 2: Memory Address, Memory Management, Memory Leak
Document Summary
Each variable is stored at a specific memory location that has a memory address. You can use the address operator & to get the address int num = 5; cout << # //prints address in hexadecimal cout << long(&num); //prints address in decimal. The address of a memory location is a pointer, meaning that a pointer is variable that holds an address. Which can be read as intptr can hold the address of an int or the variable that intptr points to has type int. An array name is the starting address of the array. Cout << &vals{0} //should print the same address as vals. An array name can be used as a pointer const. A pointer can be used as an array name. The only difference between arrays names and pointer variables is that you cannot change the address an array name points to because array names are pointer const.