{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Variablesreferencethe contentsofalocations

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

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 ► ADDR1 ADDR2 ADDR3 ADDR4 ADDR5 ADDR6 Contents1 ADDR11 Contents11 * * * * * ADDR16 Contents16 Pointer Variable 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 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

{[ snackBarMessage ]}

Ask a homework question - tutors are online