This preview shows page 1. Sign up to view the full content.
Unformatted text preview: f Address and Pointers
Memory can be conceptualized as a linear set of data locations.
► Variables reference the contents of a locations
► Pointers have a value of the address of a given location
ADDR6 Contents1 ADDR11 Contents11 *
* ADDR16 Contents16 Pointer Variable
► Assume ptr is a pointer variable and x is an integer variable
x 10 ptr &x
Now ptr can access the value of x. x = 10
ptr = &x HOW!!!!
Write: *variable .
Cout<<*ptr; For example: POINTERS
► Consider the statements:
FILE *fptr1 , *fptr2 ; /* Declare two file pointers */
int *aptr ; /* Declare a pointer to an int */
float *bptr ; /* Declare a pointer to a float */
Int a ; /* Declare an int variable */
Float b ; /* Declare a float variable */ Declaring a Po...
View Full Document
This document was uploaded on 03/16/2014.
- Spring '14