Page 80 - DCAP201_FUNDAMENTALS_OF_DATA_STRUCTURES
P. 80
Unit 5: Pointers
14. If the records may contain .................... data, then the elements of a record cannot be stored Notes
in an array.
15. In .................... , elements in the different arrays with the same subscript belong to the same
record.
5.4 Summary
A pointer is a variable which contains the address in memory of another variable.
A pointer must be defined to point to some type of variable. It cannot be used to point to
any other type of variable or it will result in a type incompatibility error.
When an array is passed to a function what is actually passed is its initial elements location
in memory.
Arrays of Pointers are a data representation that will cope efficiently and conveniently
with variable length text lines.
When we pass a 2D array to a function we must specify the number of columns — the
number of rows is irrelevant.
A record is a collection of related data items, each of which is called a field or attribute, and
a file is a collection of similar records.
In order to specify a particular item, we may have to qualify the name by using appropriate
group item names in the structure.
In parallel arrays, elements in the different arrays with the same subscript belong to the
same record.
5.5 Keywords
& Operator: The unary or monadic operator & gives the "address of a variable".
Arrays of Pointers: Arrays of Pointers are a data representation that will cope efficiently and
conveniently with variable length text lines.
Dereference Operator: The indirection or dereference operator * gives the "contents of an object
pointed to by a pointer".
Parallel arrays: In parallel arrays, elements in the different arrays with the same subscript
belong to the same record.
Pointer: A pointer is a variable which contains the address in memory of another variable.
Record: A record is a collection of related data items, each of which is called a field or attribute,
and a file is a collection of similar records.
Strings: Strings are defined as arrays of characters.
Strlen(): strlen() is a standard library function that returns the length of a string.
5.6 Review Questions
1. Illustrate the concept of pointers with example.
2. Describe the relationship between pointers and functions with example.
3. Explain how arrays are passed to functions.
LOVELY PROFESSIONAL UNIVERSITY 73