Pointers to Pointers and Array of Pointers

[Pages:44]Chapter 15:

Pointers to Pointers and Array of Pointers

int myVar; int *ptr; myVar = 12; ptr = &myVar;

int myVar; int *ptr; int **ptr_to_ptr; myVar = 12; ptr = &myVar; ptr_to_ptr = &ptr;

int myVar; int *ptr; int **ptr_to_ptr; myVar = 12; ptr = &myVar; ptr_to_ptr = &ptr;

"The two worlds" become "The three worlds"!

& is the "escalator up" * is the "escalator down"

ptr_to_ptr ptr

myVar

Your turn:

Important application of p2p: Two-dimensional arrays

int a[3][4];

Important application of p2p: Two-dimensional arrays

int a[3][4];

What is common to all elements in a row?

................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download