Basic terminology-pointers

Basic terminology-pointers - 8: Basic Terminology A pointer...

Info iconThis preview shows pages 1–7. Sign up to view the full content.

View Full Document Right Arrow Icon
8: Basic Terminology A pointer is a variable whose value is a memory address representing the location of the chunk of memory on either the run- time stack or on the heap. Pointers have names, values and types. versus value pointed to by p 24 p
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
8: Declaring and Casting Pointers For any C data type T, you can define a variable of type "pointer to T": int *p; pointer to int , or int pointer char *q; pointer to char , or char pointer double **w; pointer to pointer to double
Background image of page 2
Pointers The placement of the whitespace around the asterisk in a pointer declaration: int* p; int * p; int *p; I use the third convention
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Declaring pointers To declare two pointers of the same type, use int *p1, *p2; rather than int *p1, p2;
Background image of page 4
8: Dereferencing Pointers and the Address Operator int *p; p is an int pointer, *p is the contents of the memory object points to; ( *p variable) 24 *p p
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
8: Dereferencing Pointers and the Address Operator int i; i is an int variable &i is like an int pointer, pointing to the variable i 24 i &i
Background image of page 6
Image of page 7
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 02/18/2012 for the course CS 240 taught by Professor Rego during the Fall '08 term at Purdue University-West Lafayette.

Page1 / 13

Basic terminology-pointers - 8: Basic Terminology A pointer...

This preview shows document pages 1 - 7. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online