Welcome to Scribd, the world's digital library. Read, publish, and share books and documents. See more
P. 1
Lec 6 Pointers

Lec 6 Pointers

Ratings: (0)|Views: 40 |Likes:
Published by faizan260690

More info:

Published by: faizan260690 on Apr 14, 2010
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as PDF, TXT or read online from Scribd
See more
See less

01/01/2014

pdf

text

original

 
11
Dept. of CSE, IIT KGP
PointersPointers
CS10001:CS10001:Programming & Data StructuresProgramming & Data Structures
Prof.Prof.PallabPallabDasguptaDasguptaProfessor, Dept. of Computer Sc. &Professor, Dept. of Computer Sc. &EnggEngg.,.,Indian Institute of Technology, Kharagpur Indian Institute of Technology, Kharagpur 
 
22
Dept. of CSE, IIT KGP
IntroductionIntroduction
A pointer is a variable that represents the location (rather thaA pointer is a variable that represents the location (rather thannthe value) of a data item.the value) of a data item.
They have a number of useful applications.They have a number of useful applications.
 –  – 
Enables us to access a variable that is defined outside theEnables us to access a variable that is defined outside thefunction.function.
 –  – 
Can be used to pass information back and forth between aCan be used to pass information back and forth between afunction and its reference point.function and its reference point.
 –  – 
More efficient in handling data tables.More efficient in handling data tables.
 –  – 
Reduces the length and complexity of a program.Reduces the length and complexity of a program.
 –  – 
Sometimes also increases the execution speed.Sometimes also increases the execution speed.
 
33
Dept. of CSE, IIT KGP
Basic ConceptBasic Concept
In memory, every stored data item occupies one or moreIn memory, every stored data item occupies one or morecontiguous memory cells.contiguous memory cells.
 –  – 
The number of memory cells required to store a data itemThe number of memory cells required to store a data itemdepends on its type (char,depends on its type (char,intint, double, etc.)., double, etc.).
Whenever we declare a variable, the system allocatesWhenever we declare a variable, the system allocatesmemory location(s) to hold the value of the variable.memory location(s) to hold the value of the variable.
 –  – 
Since every byte in memory has a unique address, thisSince every byte in memory has a unique address, thislocation will also have its own (unique) address.location will also have its own (unique) address.

Activity (8)

You've already reviewed this. Edit your review.
1 thousand reads
1 hundred reads
Laxman Pandey liked this
tunvy liked this
kalyaniradha liked this
anukur_kit liked this
bhaskar_devan liked this
janybasha liked this

You're Reading a Free Preview

Download
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->