Академический Документы
Профессиональный Документы
Культура Документы
POINTER:-
A pointer is a variable that holds the address of another variable.
POINTER TO POINTER:-
Pointer-to-pointer holds address of another pointer. So it requires double
dereferencing to obtain the value object.
EXAMPLE:-
int **p;
ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
c
The value of each variable is written inside each cell; under the cells are
their respective addresses in memory.
The new thing in this example is variable c, which can be used in three
different levels of indirection, each one of them would correspond to a
different value:
×c cc× ccc
c
cc
×c cc× ccc
c
c c
×c cc× ccc
c
c
c
PROGRAM:-
P
P
P
P P
P
P
P !
P
P !
P "#
P
P
LINKED LIST:-
A linked list or one way list is a linear collection of data elements, called
nodes, where the linear order is given by means of pointers .That is each
node is divided into twocparts: the first part contains the information of the
element, and the second part, called the linked list or next pointer field,
contains the address of next node in the list.
The pointer of last node contains a special value, called the null pointer,
which is any invalid address.
EXAMPLE:-
A hospital ward contains 12 beds, of which 9 are occupied .We want an
alphabetical listing of the patients. we use variable START to point first
patient. Hence START contains 5, since the first patient, Adams, occupies
bed 5.Also Adams¶s pointer is equal to 3;Since Dean the next patient.
START ß
ÿ
ÿ
c c
c c
c c
c
c c
c
c
c
START c c
c c
c
c c
c
c c
c c
c
c
c c
c c
c
c c
c c c
c
c c
c c
c
c c
c
c c
c c c ÿ
c c c
c c
c
c c
c
c c
ÿ
c c c
c
c c
EXAMPLE:-
In this picture a linked list in memory where each node of the list contains a
single character.We can obtain a actual list of charactera, or ,in other
words, the string ,as follows:
# '
( #&
GARBAGE COLLECTION:-
cccc#c
&c cc$!' cc
cccccccccccccccccccccccccccccccccccccccccccccccccccccccc
c
ÿ
c
START
c
c
c
c
c
ÿ
AVAIL
c
c
c
c
c
MALLOC FUNCTION IN C:-
c(ccc
c
c
c