1 / 34

Objectives

Chapter 9 Pointers. Objectives. ❏ To understand the concept and use of pointers ❏ To be able to declare, define, and initialize pointers ❏ To write programs that access data through pointers

hope
Download Presentation

Objectives

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Chapter 9 Pointers Objectives ❏ To understand the concept and use of pointers ❏ To be able to declare, define, and initialize pointers ❏ To write programs that access data through pointers ❏ To use pointers as parameters and return types ❏ To understand pointer compatibility, especially regarding pointers to pointers ❏ To understand the role of quality in software engineering Computer Science: A Structured Programming Approach Using C

  2. FIGURE 9-1 Derived Types Computer Science: A Structured Programming Approach Using C

  3. 9-1 Introduction A pointer is a constant or variable that contains an address that can be used to access data. Pointers are built on the basic concept of pointer constants. Topics discussed in this section: Pointer Constants Pointer Values Pointer Variables Accessing Variables Through PointersPointer Declaration and DefinitionDeclaration versus Redirection Initialization of Pointer Variables Computer Science: A Structured Programming Approach Using C

  4. FIGURE 9-2 Character Constants and Variables Computer Science: A Structured Programming Approach Using C

  5. FIGURE 9-3Pointer Constants Computer Science: A Structured Programming Approach Using C

  6. Note Pointer constants, drawn from the set of addresses for a computer, exist by themselves. We cannot change them; we can only use them. Computer Science: A Structured Programming Approach Using C

  7. Note An address expression, one of the expression types in the unary expression category, consists of an ampersand (&) and a variable name. Computer Science: A Structured Programming Approach Using C

  8. FIGURE 9-4 Print Character Addresses Computer Science: A Structured Programming Approach Using C

  9. Note A variable’s address is the first byte occupied by the variable. Computer Science: A Structured Programming Approach Using C

  10. FIGURE 9-5 Integer Constants and Variables Computer Science: A Structured Programming Approach Using C

  11. FIGURE 9-6 Pointer Variable Computer Science: A Structured Programming Approach Using C

  12. FIGURE 9-7 Multiple Pointers to a Variable Computer Science: A Structured Programming Approach Using C

  13. Note A pointer that points to no variable contains the special null-pointer constant, NULL. Computer Science: A Structured Programming Approach Using C

  14. Note An indirect expression, one of the expression types in the unary expression category, is coded with an asterisk (*) and an identifier. Computer Science: A Structured Programming Approach Using C

  15. FIGURE 9-8 Accessing Variables Through Pointers Computer Science: A Structured Programming Approach Using C

  16. FIGURE 9-9 Address and Indirection Operators Computer Science: A Structured Programming Approach Using C

  17. FIGURE 9-10 Pointer Variable Declaration Computer Science: A Structured Programming Approach Using C

  18. FIGURE 9-11 Declaring Pointer Variables Computer Science: A Structured Programming Approach Using C

  19. PROGRAM 9-1 Demonstrate Use of Pointers Computer Science: A Structured Programming Approach Using C

  20. PROGRAM 9-1 Demonstrate Use of Pointers Computer Science: A Structured Programming Approach Using C

  21. FIGURE 9-12 Uninitialized Pointers Computer Science: A Structured Programming Approach Using C

  22. FIGURE 9-13 Initializing Pointer Variables Computer Science: A Structured Programming Approach Using C

  23. PROGRAM 9-2 Fun with Pointers Computer Science: A Structured Programming Approach Using C

  24. PROGRAM 9-2 Fun with Pointers Computer Science: A Structured Programming Approach Using C

  25. PROGRAM 9-2 Fun with Pointers Computer Science: A Structured Programming Approach Using C

  26. FIGURE 9-14Add Two Numbers Using Pointers Computer Science: A Structured Programming Approach Using C

  27. PROGRAM 9-3 Add Two Numbers Using Pointers Computer Science: A Structured Programming Approach Using C

  28. PROGRAM 9-3 Add Two Numbers Using Pointers Computer Science: A Structured Programming Approach Using C

  29. FIGURE 9-15 Demonstrate Pointer Flexibility Computer Science: A Structured Programming Approach Using C

  30. PROGRAM 9-4 Using One Pointer for Many Variables Computer Science: A Structured Programming Approach Using C

  31. PROGRAM 9-4 Using One Pointer for Many Variables Computer Science: A Structured Programming Approach Using C

  32. FIGURE 9-16 One Variable with Many Pointers Computer Science: A Structured Programming Approach Using C

  33. PROGRAM 9-5 Using A Variable with Many Pointers Computer Science: A Structured Programming Approach Using C

  34. PROGRAM 9-5 Using A Variable with Many Pointers Computer Science: A Structured Programming Approach Using C

More Related