{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

# Chapter9 - Chapter 9 Pointers 1 Dr Serdar Kirli Pointer...

This preview shows pages 1–14. Sign up to view the full content.

Dr. Serdar Kirli 1 Chapter 9 Pointers

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

View Full Document
Dr. Serdar Kirli 2 Pointer Fundamentals A pointer is a variable that holds an address of a memory location rather than a regular numeric value. To declare a pointer, use the syntax type *name; where name is the name of the pointer variable and type is the type of thing that the pointer will point to. For example: float *p; int *py; double *myArray ;
Dr. Serdar Kirli 3 The “Address of” Operator The & is the address of operator. For example: p = &x; assigns the address of x to the pointer variable p . float x = 2.5 ; float *p; p = &x;

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

View Full Document
Dr. Serdar Kirli 4 The “Address of” Operator float x = 2.5 ; float *p; p = &x; The & is the address of operator. For example: p = &x; assigns the address of x to the pointer variable p . x
Dr. Serdar Kirli 5 The “Address of” Operator x p float x = 2.5 ; float *p; p = &x; The & is the address of operator. For example: p = &x; assigns the address of x to the pointer variable p .

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

View Full Document
Dr. Serdar Kirli 6 The “Address of” Operator float x = 2.5 ; float *p; p = &x; x p p receives the address of x The & is the address of operator. For example: p = &x; assigns the address of x to the pointer variable p .
Dr. Serdar Kirli 7 The “Dereferencing” Operator The * is the dereferencing operator. For example: y = *p; sets the value of y equal to the value pointed to by the pointer variable p . float y = 3.4 ; float x = 3.7 ; float *p; p = &x; *p = 7.5 ; y = *p;

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

View Full Document
Dr. Serdar Kirli 8 The “Dereferencing” Operator The * is the dereferencing operator. For example: y = *p; sets the value of y equal to the value pointed to by the pointer variable p . y float y = 3.4 ; float x = 3.7 ; float *p; p = &x; *p = 7.5 ; y = *p;
Dr. Serdar Kirli 9 The “Dereferencing” Operator x The * is the dereferencing operator. For example: y = *p; sets the value of y equal to the value pointed to by the pointer variable p . y float y = 3.4 ; float x = 3.7 ; float *p; p = &x; *p = 7.5 ; y = *p;

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

View Full Document
Dr. Serdar Kirli 10 The “Dereferencing” Operator x p y The * is the dereferencing operator. For example: y = *p; sets the value of y equal to the value pointed to by the pointer variable p . float y = 3.4 ; float x = 3.7 ; float *p; p = &x; *p = 7.5 ; y = *p;
Dr. Serdar Kirli 11 The “Dereferencing” Operator x p p receives the address of x y The * is the dereferencing operator. For example: y = *p; sets the value of y equal to the value pointed to by the pointer variable p . float y = 3.4 ; float x = 3.7 ; float *p; p = &x; *p = 7.5 ; y = *p;

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

View Full Document
Dr. Serdar Kirli 12 The “Dereferencing” Operator x p The variable pointed to by p is assigned the new value y The * is the dereferencing operator. For example: y = *p; sets the value of y equal to the value pointed to by the pointer variable p . float y = 3.4 ; float x = 3.7 ; float *p; p = &x; *p = 7.5 ; y = *p;
Dr. Serdar Kirli 13 The “Dereferencing” Operator x p y is set equal to the value pointed to by p y The * is the dereferencing operator. For example: y = *p; sets the value of y equal to the value pointed to by the pointer variable p .

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

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

{[ snackBarMessage ]}

### Page1 / 77

Chapter9 - Chapter 9 Pointers 1 Dr Serdar Kirli Pointer...

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

View Full Document
Ask a homework question - tutors are online