Page 66 - DCAP407_DATA_STRUCTURE
P. 66

Pawan Kumar, Lovely Professional University                           Unit 4: Pointers




                                               Unit 4: Pointers


               CONTENTS
               Objectives

               Introduction
               4.1 Fundamentals of Pointers
               4.2 Operations on Pointers
               4.3 Dangling Pointers
               4.4 Pointers to Functions
               4.5 Pointers and Arrays

                     4.5.1   Array of Pointers
               4.6 Records and Record Structures
                      4.6.1   Indexing Items in a Record
               4.7 Representation of Records in Memory - Parallel Arrays
                      4.7.1   Variable Length Records
               4.8 Summary
               4.9 Keywords
               4.10 Self Assessment

               4.11 Review Questions
               4.12 Further Readings
               Objectives

               After studying this unit, you will be able to:
               •    Understand the fundamentals of pointers
               •    Analyze the operations on pointers
               •    Explain dangling pointers
               •    Discuss the concept of pointers to functions

               •    Describe pointers and arrays
               •    Explain records and record structures
               •    Analyze the representation of records in memory - parallel arrays
               Introduction

               In C language, pointers are one of the strongest and the most powerful feature as they allow dynamic
               allocation of memory. Pointers are variables that point to data items. They store the reference of another
               variable. Although pointers provide flexibility while structuring data, you need to use pointers with
               caution as they can introduce bugs. These bugs cause difficulty while debugging a program.
               You can use pointers to write compact codes, thereby reducing the program length and complexity. The
               method of passing the address of an argument in the calling function to a corresponding parameter in
               the called function is called  “pass by  reference”. This method helps to access the data faster  and
               supports dynamic allocation of memory. It can be used to access the byte or word locations and CPU
               registers.  Dangling pointer is a pointer  that  points to a  deleted  object.  Uninitialized pointers having



                                        LOVELY PROFESSIONAL UNIVERSITY                           59
   61   62   63   64   65   66   67   68   69   70   71