Programming for problem solving
ES CS201
Content
Pointers
Pointers
A pointer is a variable that store memory address. Like all other variables it also has a
name, has to be declared and ocupies some space in memory. It is called pointer because
it points to a particular location in the memory by storing the address of that location.
The use of pointers makes the code more efficient and compact. Some of the uses of
pointers are- -
(i) Accessing array elements.
(ii) Returning more than one value from a function.
(iii) Accessing dynamically allocated memory.
(iv) Implementing data structures like linked lists, trees, and graphs.
Memory
it is necessary to declare a variable before using it, since compiler has to reserve
space for it. The data type of the variable also has to be mentioried so that the
compiler knows how much space needs to be reserved. Now let us see what
happens when we declare a variable. Suppose we declare a variable age of type
int-
Address Of Operator
Declaration Of Pointer Variables
Assigning Address To Pointer
Variables
if we have an integer pointer pI then we can assign the value of iptr to it as-
Dereferencing Pointer Variables
Pointer Arithmetic
Precedence Of Dereferencing Operator And /Increment/
Decrement Operators
Pointer Comparisons
Pointer To Pointer
Pointers and One Dimensional
Arrays
Pointer to an Array