Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ
Tải xuống
Using const with Pointers • const qualifier – Value of variable should not be modified – const used when function does not need to change a variable • Principle of least privilege – Award function enough access to accomplish task, but no more • Four ways to pass pointer to function – Nonconstant pointer to nonconstant data • Highest amount of access – Nonconstant pointer to constant data – Constant pointer to nonconstant data – Constant pointer to constant data • Least amount of access. | 1 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 const with Pointers 5.6 Bubble Sort Using Pass-by-Reference 5.7 Pointer Expressions and Pointer Arithmetic 5.8 Relationship Between Pointers and Arrays 5.9 Arrays of Pointers 5.10 Function Pointers 5.11 Introduction to Character and String Processing 5.11.1 Fundamentals of Characters and Strings 5.11.2 String Manipulation Functions of the StringHandling Library 2003 Prentice Hall Inc. All rights reserved. 2 Pointer Variable Declarations and Initialization Pointer variables - Contain memory addresses as values count - Normally variable contains specific value direct reference - Pointers contain address of variable that has specific value indirect reference countPtr count Indirection k 7 - Referencing value through pointer Pointer declarations - indicates variable is pointer int myPtr declares pointer to int pointer of type int - Multiple pointers require multiple asterisks int myPtr1 myPtr2 2003 Prentice Hall Inc. All rights reserved. 3 Pointer Variable Declarations and Initialization Can declare pointers to any data type Pointer initialization - Initialized to 0 NULL or address 0 or NULL points to nothing 2003 Prentice Hall Inc. All rights .