pointer - 1 2000 Deitel & Associates, Inc. All...

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

View Full Document Right Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon

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

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

Unformatted text preview: 1 2000 Deitel & Associates, Inc. All rights reserved. 2000 Deitel & Associates, Inc. All rights reserved. Chapter 5 - Pointers and Strings Outline 5.1 Introduction 5.2 Pointer Variable Declarations and Initialization 5.3 Pointer Operators 5.4 Calling Functions by Reference 5.5 Using the Const Qualifier with Pointers 5.6 Bubble Sort Using Call-by-reference 5.7 Pointer Expressions and Pointer Arithmetic 5.8 The Relationship Between Pointers and Arrays 5.9 Arrays of Pointers 5.10 Case Study: A Card Shuffling and Dealing Simulation 5.11 Function Pointers 5.12 Introduction to Character and String Processing 5.12.1 Fundamentals of Characters and Strings 5.12.2 String Manipulation Functions of the String-handling Library 5.13 Thinking About Objects: Interactions Among Objects 2 2000 Deitel & Associates, Inc. All rights reserved. 2000 Deitel & Associates, Inc. All rights reserved. 5.1 Introduction Pointers Powerful, but difficult to master Simulate call-by-reference Close relationship with arrays and strings 3 2000 Deitel & Associates, Inc. All rights reserved. 2000 Deitel & Associates, Inc. All rights reserved. 5.2 Pointer Variable Declarations and Initialization Pointer variables Contain memory addresses as their values Normal variables contain a specific value (direct reference) Pointers contain the address of a variable that has a specific value (indirect reference) Indirection Referencing a pointer value Pointer declarations * indicates variable is a pointer int *myPtr; declares a pointer to an int , a pointer of type int * Multiple pointers require multiple asterisks int *myPtr1, *myPtr2; count 7 countPtr count 7 4 2000 Deitel & Associates, Inc. All rights reserved. 2000 Deitel & Associates, Inc. All rights reserved. 5.2 Pointer Variable Declarations and Initialization Can declare pointers to any data type Pointers initialization Initialized to , NULL , or an address or NULL points to nothing 5 2000 Deitel & Associates, Inc. All rights reserved. 2000 Deitel & Associates, Inc. All rights reserved. 5.3 Pointer Operators & (address operator) Returns the address of its operand Example int y = 5; int *yPtr; yPtr = &y; // yPtr gets address of y yPtr points to y yPtr y 5 yptr 500000 600000 y 600000 5 address of y is value of yptr 6 2000 Deitel & Associates, Inc. All rights reserved. 2000 Deitel & Associates, Inc. All rights reserved. 5.3 Pointer Operators * (indirection/dereferencing operator) Returns the value of what its operand points to *yPtr returns y (because yPtr points to y )....
View Full Document

Page1 / 38

pointer - 1 2000 Deitel & Associates, Inc. All...

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