Escolar Documentos
Profissional Documentos
Cultura Documentos
Group Members:
© 2010 Tieto Corporation
Kavitha Sreekumar
Nitin Chavan (GL)
Sahitya Gollapalli
Vinay Mandge
Contents
• Introduction to Pointer
• Pointer advantages
• Declaration of Pointers
• Pointer Arithmetic
• Pointers to Arrays and strings
• Pointers and Structures
• Pointers to functions
0
1
Representation of variable
2
. Quantity Variable
. 150 Value
. 4500 Address
• Declaration :-
• Initialize :-
2010-03-26
Use of & and *
• • When is & used?
• • When is * used?
2010-03-26
Pointer Arithmetic
• Operations such as Increment & Decrement.
• E.g.:-
# include <stdio.h>
char movie[] =“Jurassic park”;
main()
{
char *ptr;
ptr=movie;
printf(“%s”,movie);
printf(“%s”,ptr);
ptr++;
printf(“%s”,movie);
printf(“%s”,ptr);
}
2010-03-26
Pointer and Array
• Declaration :
int *nptr ;
Base
address
2010-03-26
Pointers to Array
• Declaration :
int *nptr ;
nptr = number[0] ;
or
nptr = number ;
nptr
10 2010-03-26
Array of Pointers (Ragged arrays)
• Declaration :
char *name[3] = {
“New Zealand” ,
“Australia” ,
“India” ,
}
11 2010-03-26
Pointers to String
Example :
int length
char *str = “good” ; ;
G O O D \0
while (*cptr != ‘\0’) ;
12 2010-03-26
Pointers to functions
2010-03-26
© 2010 Tieto Corporation
Thank You