Page 65 - DCAP201_FUNDAMENTALS_OF_DATA_STRUCTURES
P. 65

Fundamentals of Data Structures                                Kumar Vishal, Lovely Professional University




                    Notes                                      Unit 5: Pointers


                                     CONTENTS
                                     Objectives
                                     Introduction

                                     5.1  Concept of Pointers
                                          5.1.1  Pointer and Functions
                                          5.1.2  Pointers and Arrays

                                     5.2  Arrays of Pointers
                                          5.2.1  Multidimensional Arrays and Pointers
                                          5.2.2  Static Initialisation of Pointer Arrays
                                     5.3  Records and Record Structures
                                          5.3.1  Indexing Items in a Record

                                          5.3.2  Representation of Records in Memory; Parallel Arrays
                                     5.4  Summary
                                     5.5  Keywords

                                     5.6  Review Questions
                                     5.7  Further Readings

                                   Objectives

                                   After studying this unit, you will be able to:

                                       Discuss the concept of pointers
                                       Explain array of pointers
                                       Discuss records and record structures
                                       Explain representation of records in memory, parallel arrays

                                   Introduction

                                   A pointer is nothing but a variable that contains an address of a location in memory. Pointers are
                                   used everywhere in C, and if you have a good understanding of them C should not pose a
                                   problem. C pointers are basically the same as Pascal pointers except they are used much more
                                   freely in C. A pointer is a variable that points to another variable. This means that it holds the
                                   memory address of another variable. Put another way, the pointer does not hold a value in the
                                   traditional sense; instead, it holds the address of another variable. It points to that other variable
                                   by holding its address. Because a pointer holds an address rather than a value, it has two parts.
                                   The pointer itself holds the address. That address points to a value. There is the pointer and the
                                   value pointed to. This fact can be a little confusing until you get used to it. In this unit, we will
                                   discuss the concept of pointers and array of pointers. We will also discuss the concept of record
                                   and record structures.





          58                                LOVELY PROFESSIONAL UNIVERSITY
   60   61   62   63   64   65   66   67   68   69   70