Professional Documents
Culture Documents
INTRODUCTION TO POINTERS
28‐Jun‐20 ARJ 1
What is Pointer?
Consider a variable
declaration… count Location name
3456 Address of location
◦ Reserve 4 bytes of memory
space from address 3456…
◦ Named it as count…
◦ Store 10…
28‐Jun‐20 ARJ 4
What is Pointer?
How to access the value?
◦ Name count Location name
◦ address 10 Value at location
3456 Address of location
28‐Jun‐20 ARJ 5
What is Pointer?
Can we store memory address in
variable?
◦ Yes… count Location name
28‐Jun‐20 ARJ 6
What is Pointer?
A variable that holds memory address…
28‐Jun‐20 ARJ 7
Operators used in Pointers
Address Dereferencing
& *
Address of Value of
28‐Jun‐20 ARJ 8
How to use Pointer?
Consider the following
statements… count ptr
- int count = 10;
- int *ptr; // pointer to integer 10 3456
- ptr = &count;
3456 5000
28‐Jun‐20 ARJ 9
Accessing a variable through its pointer
count ptr
10 3456
3456 5000
count ptr
100 3456
3456 5000
28‐Jun‐20 ARJ 10