ONC
la)
Pointexa *
“gpeiieis qua. dal Vatlebled that conzain
dhe addraas % da ob Vostable -
Xx The Vasile thatched daa.
AkQ catted pointers. > ov 2}
$B). im ace
* lool tg dite oddregs % the Variable. a. &
dia numorit. address, ckored fo He ancthal Vaulable
,b having address loan. .
mamoty addresses
' °}
adico | 5
b— lo20 Leos
Advantages of _ poinkexs i=
% poinkars fotsecseg the execution & paad of
dha program - ;
& Poi nlovs yeduces The lens and complexity
Of a Pargsam . ; c :
x Pointers enabh Us fo aceon @ Youiable
thal 28 clog na cubside. ns Punckin,
& polaters “cial wed ko pow infovrnael er
back Bnd forth bebwen a funckion and its seperna
Point. ,
»% Poinkers reduces waskage BE momry
Lohile Adoring character Absngs.@
(2.12
yatfable.
any yarfablo. Can be.
add ¥o.35 Of;
The. oddwoas A;
dhe holp of tHe add vass Ope
Accoasthg He
accessed aifh
Q.
x The general oven By
(Bratane |
4 bok an inkego- Vari ad @ quonaty
Usntains Volso of angi
Pre gnankity = 74 5
xThe address of, te Voriabla quanety
Ba go& ky theo addroas oparctire QZ and aualgnad ko
jan Inbagok Vaslable. P. 1
Eg). Variable. Vvobuo Add ross
quanti dy Gat So
e ay BRS
£9). ZA, ex(sjeke-
and Datiatining Pol ators
: a Pll power Vasiable.
declared before A is used fy dhe Program.
x The generat dsc Ls
Declaring
wsk be—
Jaketype xvartable +“y
key
whae , daketype - ype of de Vortable polriof
by poinkey vartable
® ®
Vartable— \yabtd o yartable Mame
Riles i
% Pointer Veuiables swould bo Valed © vaslaple
Dame -
Ee Askerbk Ge) a nok tee pouk
pane but Le 2 ty denote tho Ayre of tha
ak tho Variable
Vasiabla as pointer,
ve Dake typo wopors tothe type the Variable
pointes by tye polmter Variable nes
x Dritialy the pointer docs not pole bo
ansptnthg bub she programa nuk axsigo ie
Vole » } ,
Eg inink *o)
—> dactaros tie var?
yasfabia that polnks b 0
abla: Q as & pointer
Integer Value: 2)
dy Floak *b,
Sdacaros the vatiable b as % poinkor
Variable drat points t an Bloating poink variable,
Gin SHE HELb yor Ark bw;
D> declares quo Vertable, Q as potntor
Variable that points ko an
lino Variabla. b ax imply the Aype Tateager.
- Gy) (Me xa, #B
declares tha Vatiables a
Woxiables thot points to an integor Vourable.
Vk og or. Vasfable and
and 6 ow poinkaradd vo 3s of ha Vadable =
yariebla ca,
Amigning Ate
ge the ocldrass Tos
ba gok wrth dae holp Of tte odadwoas
| / ~The goneral Loren Bs
pol Hear yotlable avedabie|
pol neon variable,
ohne , Polder vaiablie _ dectated
g. —addra os porate
Vastable — Orolo ates Yar able.
operaksr g ,
| EQ) gy Soke KH Y
js XF
arex,
Tho momery address of Ha variable » 2s
porsigned Ro He «polnber Variable a. Ky, yooi is he
address of The variable %) © gok whe value loo).
(Ti) Ink #Y)
ine bY
be *Y
The coukenk of the poinkor
bo Ha Vatiabla b- Nok ua MoNoy address,
ii) Bok aLlody prone oh
Voul abla y fa anrsig nao
ink’ #b
pe 200 5.
The memory addvoss of the “sth jam Fo tho ax
ak arsignad Io dha palukar Yaulable 6. J
f ones ShAccosstg a D Vas table. Herough fs pot nkoxz- ,
XT Value of a Variable can be
Access ad uatag pointe Vastable ,
% Tha genaral torn B
* Pointor varfable 5.
WMe, x _ Inolerection operator
Oeeeatel~ clectated pointer Vasiale.
Vvasiabla! :
Fg). int’ ex: —pdectate..xias poinker Vastable.
ink ys
Y = ao;
Xo By, —> arslges the address of y to
poi wet Vattabla x
PHREL CWA” yx) —p prints 200TH value of
Voutabley
pink crdl DX) —> panks dro acthrest of Po
VorPable yg
Sample programs i- t
i){wrie a rare ko display He. conkanks of &
'
vifpoinke. vastable »
stinclude
.
gpinclude < cxilo h7” : be
Void madnts
b _i)
4
int a}
Srl xb;
asloo;
b= 2a ;
prinkE tie | contonk of tka potnka be yol\o", #6),
getcht) ;
3
| output:
| Tha contort of ta Polaber, be 100
Write a program ko otis play Ane Contents and
address of A poinkor Vadable .
aefoclucta < ekdto, hz
Aeincticke < conto hy
org maiko)
i
fol a}
int ¥b;
2100;
p22oe
prink(" Ha contenk of Sue polar b> zd ol,
Xb);
Pores the address oh, tia, polakor be Yao’, b);
getcht )
3 = ——— EE
@ wp
Pha Conkenk of jus ipointau: b # 10°
tthe adldre as of eo. peineos b> R542
|
Pointer expro Bsien '-
pragsim Oo dine
MPolwsor. ex
and
|
Comb! nottt im of pointor Variables, vaslables
op a
x PE gives osttpar num ead
| addrvess owl pul.
|
(2g). Apa +O, LPH »
output oY
we teop) pau , PEE.
| Poi ntox agafgneent : L
|
eT gencral form “ha
|
|
‘ ‘Waaiable = poinkou expeassy
| ror Voniaele
wo Wnere yartabo — oxsinaey ox potreot
,
= aogier: opaatoy,
| Bg), [Ue ass, bs
folk #P V2
| po 2a ejee —
Ge tbee
Has epee -
the Valua of b
| ¥ ptto ane its value B IS>
|
jeielaties eer eee St
cateatated by 4ho express218,
Pointer ari Humelfe ‘-
THE Polloutng four anfdtomatte. opal oy
can bes. performed wit poi nkaws,
add&icv, ++
Sdubbrackiol —
Tocromartation +H
docrontoxtabion — —
2 poiakor Poyorms ft Operabfun fo ‘ykea
Of tia approprake Skovaga class cy Scala, Packt ov
angi of dlotaclype.
Prere monks and scale factor I
% Preremonk moc adding one Jeo the
pointer Variable .
! HPoinkor Variable contains tho adalwoss
| other \afaplar, 8 adding one Moana changing dha
odie. Ao he pox ee a
tds chooge dower plc 2 torms oy |
te sine Fe Rengtn 4 tre daka type catlect ‘gale — |
|fattor.
| Dakatype Scalater thoy
Chouackor | byke_
ir On abyke
floaks Ag ko
Long Inbegor Habla ¢
Aouble Bbykoy,9/8
&
3 |
4
i
Q), X2Yy are polubar Vasiahlos . Dn x, aaldvers Of Aue
Vatiabla aq Zs Abor ed.
Lok qua addross Of Variable BX tor, |
A). Yo mt means scala faclar os Wego 4a)
Rbyko be cated) ty times bo, dha. Value o& x ond
Y poincor kateas tue Value [020+ @ ab) tore.
b). ges maces dna acale Sacto’ ap apes 4)
a byko i Authksoclo by Samos fo Jaa Value ob TES
pointer Latees ua Valo jor -2 = (Ol&.
C). Mt mec Hae Arale Lackor dey a byke Ls
adcted bo Ho Val of x Bay (oped = (O22-
dA) w—— moans deo rala factor jy, aby ko Fs
| gunterct af Ao Wie. Value of pj By lone 2-118
Progra ank2
rps LWUYD wsrbhe ,
Rok ALG
we Qo,
az2zX.J
&
2 ott ob deo polnso. Vatiane
a) ye vat
vay ao mand fy ond) Rabel Yala
Ql.
b). Yo Ma = Moats Y kates the Valet 26-1 21g
voleos fia VYalus 2045 > 26
c). Ye Xayrmeanw Y
kaos te Value 20-8 215
AY ye Ha —Si mean
| Sample progroms: !-
ie wy
onto a prgran “oe ctr play ua, pointer add vo.
bopore ond ofkor Fnerananbaktom -. oj 4
seincluda < akdto -h>
| feincluda
Void malo)
4
ine as
Sok xby
Q@x2looy |
c baa}
| PBREKL" mamwory
yarn xb)
bt+ > omonbalt
Ponts (" manory address aybar in ° |
yarn! eb) 5
adolress bepore revo manbaben |
getche 3 7
32).
oul puk *
monuory addwoss before Jncramomalt mn 5422.
Sry addlvess: after Fncromankalh ow 5424
wate a . program oe Aispley tuo conbenk Of ©
Polnzer variable bafore andl after adding % Volua 5
Hincluda 4 gbdio-h7
BP ocucta x oonlo-h7
Yoiel mafnc ) :
L.
hk ay
Fnk xby
Az\ooy
-b2 kay : ‘
ponek content & b before, adting
5 = va \0', *b) 5
b2kb455
pir (Mconkent ob alba. adttG 5 = vd
Ao! bd 30OG
pointers and arrary j-
¥ PyTay name dah bo clofined 4s A eomcheny
PF acer facts’ points to fio addrow a Sa fPrat
elomerk Bn +o ones
Disfeonw pat woon annoy nama and pol near *
Array pornker
pointeor bs a Voi able
and cao APPear cu —
Fhe Soft dafole % an
aurigonmonk oporakor.
d) BEL a conskank ond
Ds connol- appoeow ct. Fhe
Jopie siete of ar acestyrment
Oporatavy .
Pointers and one dimemional arvosy
a Pay operation con ba dow by
ave cod bo due with) poinber! 4
% Opaakm wing pointer Ba faker
thon duak GB Buroy aabsuiphi rg.
' ' THE clomanks (ofa Qvroyy GAS
dbored GmlBguowly and aro alt of ams. Saspe.,
only FW gaictvass of ra -fiyste clamenk Zs rweded bo
access dO ontire awry, 5
mw Tho addveas of dia Livak olomarle
& gx by Zafoy whore aA —Kame af Te cur veg, quis
Lr assigned to a polnker Variable Kes Keka].
ot| ates.“ Leary gives us conkerk of
ler) motor, or x2 2a0T
The advo ss f ho ronatntng, Slomonta qua got
by adding dre scale factor te dle peinkes VasioHo
naz gives ao
Bh) xa l gives dae adavour acd
3) of 2
sak
OAdwegs gq alas and xXdn gives the act AYO
at. 4
x Yee gives dhe content op ane fret ele mant
eo aocond element
daa conzent ag qua Accor
AOJ and x[xdaj gives
os faa. Vala ob ath
eloment ary ang xCein) gir
Clomrone. whe XK — pankor Jo Tha aremay &
Eg). consid at cthran eftananto, ;
Skauding adel ress op dna armay Bs loo,
Foch olament 1 dia array occapfes ts bytes .
Skatic nt abay = {a0 30,53 5 q
Bole XX}
Bole Y >
mA A603 ACT 4&2
wo | 3] >
joo. 102 boy
> Pk poinks ora actd x3 ae Brak cloment A£o) 2b
Loo £3 oxi grod Be dao’ painter variable X.
Ki) x= 2a 2 i
eddy : eeS|. : se weil Tp cre mont jan, Valun of
| ale gator brow. loo bp (ea, cours 43 Jaa AA ra
) ok and.
Qi), X>Rafey
| Je xcoetty
The Value Shore tn, tho locator a bis i
| Amigo ed ko Ha Vattablo y st, y tacos tea Vetue 3o
HW ee Vatay ,
| 8 Ye Mos
The Value shared in due located on ated & adlelay
[with 5 wad y taney ne Value bs.
pPomple Prograns.
) y ud te a pro gran be dinplay na. “Cowkenks Of 20 array
| i wasing Polnteay |
Aeineliclec akelio. >
fetoctucte < vonto- hy
Void maint)
2 ; gt
Bhakic Wwe aly: > Lio, 20,39, Wh;
Loko ab J
inte Lp
‘ “ey ia Lady rm
PanttC' contents of sa oorrau\a)
foc Ctz0 7 bch 7th) x
{
Punet(y¥d\a', cs J gtety 3oe
| es oukpuk |
lo
20
30
40
sho conkents of Om
Write a& program ke Aun
orrnay uating potnter .
fefociude
ime Pysums 07
bo 2a, .
z o forlero 7 4 7EAd) 5 +
dado 2 cum PR EHPD:,
Banke yA\ol, an) 5
GokehU ys x
oakpuk Ys vite 9
lo
Oo.
fied and wo Ainansional’ axrayy |.
+ Bowe Cle moWaoett excray He actcresr
Ob deo first elemont 2 adsigned &o daa pointe \Vaxtable©
¥Th two G ahanianad avsay tha
Brak olament jh) oddreas of to oth 0 2 OT Reoluy
% anignas| do tne potnker Voulable.
eg). Bkatic ink asy[sy >| fro, 20,333 , $y0,50,608
$710, 20,9285 5
fok #%)
Kz LAID, Wi) X2a@
Jwogicar views 1— eS \ e
© —
lo | a 3o
! #o Sp bo
es
Puysteat ew \— 4
Kt B Kerb XS -
Poinox
sense Dene [oe Spee yet]
To Be
PAAr2ss ot lth bre APE At] -
whore - base address
Pddrass caletaion of cock array ellomor t+ |
i}
NTho addi & tio cloner APL
L fe
gok ty te forenla .
x (corto wy] -
7 wchone , xo potntat | Variable - . : is ;
KD - Number of Columns .
_The actress of ACT CO Lr,
=X FL(8 #19457
2 X+h
Tho Volun Jghovakin den QUILT 2 ACH) +50
The addyeas of amino
2 xd [eseas 4)
2X97
The Yelua stored fo 2 al(2Icid *Cx4t]> so
Relation between pol neo and Avsan
Q). Tho array nama acts as painbox te dhe erey
Besotf ond: polnts fo dia fits& element afr) ,
23). kak al,
The. momory representation &
at acy 9029
TI), The actress jof dua, hae ehlomant
At VOY 2 gos by AAG NerG ho array hana or
tho octdress, of Aissk elomont gato} to tha pointer
aby fy the
Vrasianle -
wy eed Sota Bz, dnt
Bok wp, Pra wp. 2ace-ee
(Bt he areas ob HE ee koe BO. AG. PETRLay
are get by adcling Seale Ot
Variable:
ey, Lok alo);
Sok xp;
Pray i
Pr] -addrvess of AGT |
pre — actress of Ale)
Prn — acllress of ate)
(ly), *poinkor Variable gives tha content of fra
Awst clement fan array * [polnver vasiasle +]
gives dra_conkent “of dia secono} clement Apia
jarrouy « Sn “5
a. .
Ank aaj £10, 20,308 ¢
fink xP)
_ Peas
XPS giver the Value of QB yd to
|
|
|
*(PHI)> gives tre Value of ALi 4i 20
X(praysgives die. rabue ef 'acxy te 35)
String mantpatation using pofatey +
Fdking ba (Darray: ef. chointcers(2) Lountaated by a nut) chowcict ot
‘eo.
mw Each Characker eccenpied tbybe Monit,
be Bach cman: fo dea array con O%
laacoused busing pointers .
FG}. char 4A gy) char SHU? Romo” y
a2 Rau! : ~ Choe
ar 2stel Y
Tod 2s c& pointey width poinks fio. seating
actress of ya ading “geniot
oO
Do af 22 23 24
Whore 20,21, 22,25 224 — Adare gfos.
Program \- a :
ylwate a program. Ao dakine a abtng HVS peintar)
and to pint ibs content:
Srlocurde KekdlLo.h7
Pinu
Voit matt)
1
aly wi Giioual mee terpoe) sabe) Srey
ad
a2"Reauv" »
wwile(#a} 2 '\o')
4
Paneer ve"! 7A)»
att}
3
Epeeht) *
3
ourNe
_Reno ; .
Wate a program, ko ting He, Seng ih gp given
sbsrg. a
nite FPinclu ce -
filocactex conto: h>
Veid matnt)
aL \ - ’
char ali 2
Pak £2,
cher ¥Py
gebta) y
Pz galeys
Leo, ; 5s
cohele(#p/=\0_)
t
Ltt y
Ptr; Sere
3
prine€ (ideo an of ta. acti ayale Ws
een dy
a fost 2%} OGAveay Of polars deo aban ln
The collection polteewa eor£ue poi wks
raw oe *
EpLorowe akiras Bs catlod array of potntowa fo
Skvngs .
=)
Skatic Chat
*atay > 4” NaAGeRcorc? Maprar’,
Cormanrcce§
REACH polnker (points & a particutae peaing ,
alo
a Tete mele delete (te
eT ©]
aby, | c\o ay
RO]3.5 map Pie? D
pep Tele
program +
lito a program ke ‘difina awsoy og poltkors
doo Abedings and pone Yes Concent
pio clude K gedto-h7
geinctde< Conte 17
Void mabel)
Steattc Pea C3 > prnaneRcone’ * aporery
N copageTrore "| ;
vote 27 .
\
Aorli ro, cha 7 ttt)
1
pane’ (87 d\0! , ACIT) 2
3 ;
gent aona Ee
Limikation o, array of peinbera Tp sbeinge
| Tho. value of con sty
ak the ime doclajatiny as
as HL Dey
Chat xXnanef Js Sb "Ramu", wgomul? y
But fia Value of dre AkWIy Cannock
jb given ading deang funda 94 fn wo
exol,
| Aomensl on al avereny Chasarcker go the fo) "9
* . Fao An
| Prograro, wit) nok? wow.
Chow *nhanele i
forint ino 3 6422) foH)
4
Song (na nameLOl |
3
Pointers ond funckfows !- |
* Pn ocdtoory
jna actual aigurments are
Apaddiers korea |
by Volluc . (
Jguncdions wher ao
function 2s cotter ,
Pau ed a Vabixcs c Hh
Aagumancs « tas Bb olled cout
y with Ha help of dunudion , dae
dotmet augunant> con be. |
Actual Values anol ona
Parad a address - Tate fore any change
mack to Me Conkeut af the acteesies coll! ©
Aeon Zo beth dua function and ie couting fore”fo
i |
| Tia mathod called call bY wofererce.
| pointer and punciow can PO attra hast into tO
Qpoups - }
© WD pointers at
Oi), Function walcuenlng polka
dendcion argunente
| pctenees aa fanaone mgeenis =
polars can bo wed gun Sts
formed argu monks
The cuguments rensalve. croladrad ses
Ymstecad Of, Waters.
ye Tharekore The Jgerroat cugunanks
mut be SF cuauad es petnbor Vortatle
| .
Benxal kore '- 4
datatype spsnenfon nc cemte Pal, PAE --jpaod
daratype part , daketype” peed poo
ctakectype. * PaXxn;
§
Fea tvaluey; .
hpr # Lea = okin}
sone, dakodype — HYPe Yoo fiction 6 +
Surckin none — eser; kafinadt NAME -
parlp--" jpasn - peloier vasFables & rocky.
ockul value qololra.8 104,general orm oh dunctlon calling '
[Yonetiannent (Qarg) ,@ arg?
Bair)
cd Word |
Juncklon neenta — User Lofinoch Nae .
|
| addroas Of to- acku.at
Rargt, #ALg2 --
Value pati eof bo fia formal
j para makers Part, Pare -—--
| Egy Botucted sictdo,h
3 * ft Lnclucla
Yoid matnc )
4
Ak ay
nea 2 a aH
abe (eens ——> Og” ee
vo s yal ‘
eens rd, ays
svoid “abe tP3
Ink x py-
ae
*P2 Xptro}
pants“ py;
woken daa fund abe ®) ts called dno addreu
Ck fia variable A La passed fo tna function,
% Pride abe Vdnalvaiildble: “Pl s/ clayinadmw $O xPp2 APF20 > xP lotro 230,
Program
(wae a Program +o exchange tne contents %
Buoy Vatlables using peinkena a4 fuincel on! angurens:
Hlocduaeccovte -h7
Void maint)
A
Ark a)
a2to;
2
b220)
Parke (4 tea concent bekores
Yd\e rA\n’ parbds
shincbuctax gecdeorh> |
|
i
'
1
exchange
| } exchange (2a 2boyy
prineg (sqne content apter exchange
ya \e raat, arb);
gekcnu » :
J
Void exchenge P, 4) _
iw Fp, Hy
| i
| jnt Lomp >
kemp>*p
a *
p24;xq 2 kamp +
Ho content ofp = @KChango
| tho Coubonk pte. eecheng a
|(f). Famction vekuntng pofaker
|
(ee int, Hoak etc.
| genetat form
-
lo ap
go lo
| w Punckion can Yekuin a pointer Veuluc,
dakadype #tuncKeprame (paranakor Us)
| doctarrkin sk, paramoke ;
jem Local variable dactatalioy 7
Se
f T
robuan( pa nea Variable):
; :
bers, ~
+€g), prog ram ho add dea um a
fircluole < Skctto. hy
Wwe Tadd ( arb)
Soke 4 7s
t
de zie FO eSp> 2a >
GD a> 2b
Bez Kpr ay
| arokunt Yd) |” i
| 3 t
| void maint J
| } 4
Pol & dum,
| ft arB® ,67'02
Bum 2 adel (are)
, aya? :
| Soot’ rt, some
|
pointers and Gkruckuses:-
a polnkovs o4e G48, SR
Slerackute dakadyee ane.
gens orm '-
abr Lagticld’
memba |»
| cnember 2)
mamba n}
J * Structure Variable 7
/feennmt
thee, skruckure Vatlable — pointer Variable. |
ea bo pofnka) The Mombars ob oo rao tan
be. Access ed by any owt of io doltowi ne,
| wodtrod.
{% SRruckue Vauiable) - mem bor h -
Ti) Sbrckue vartabla dS rember Yn
23).
@M. Skee — ghudent
L
Chan nane[r2d)}
int number} 7 7 é ie
3*ps; , ae
dkructuo name dbudenk
Tembers — nove, number.
Ps ~ pointer to ¢kyuckute.
mambors of, dticiank @emo acceted as.
Leps)-name Ps name
@. deuce — Skuchant
L
Chot nanofed]
}WE number}
&
Skids “dkudenk #pay t |
|
}
| (¥ps)- number ps SD number.
|
TWh bb ales’ Valfd’ thatonmant-prgvan =
asstgo Vases bo np. rare
Wale a prgram: ky
point Tn vowkenk>-
ob dro Syuckure ond
deinctucle < tldéo -h?
frinctncle Kcowlo-h7
Voie maint)
4
Sue
L
Chou none 8),
(We qumbar,
3
Show
acank(Y £aho", Psnamed J
aeane( N7dia!, Psd oumbeds
pink (S Namae 7s\e', pss rome)
PHneEL[ Number > % e\ol ps SD ovmbey)s
eu ctonk
ee skuderk XPS 4
getehty;
7 3 +
Dynan cc memory mancge a
Memory mma ganar « ee
#IL Ba proceas of manogig Me
Compuker manory.
% Ph thks, He avoilsble memory LPalos PR the PMATams
Ls alo cakaq ko dio Voor?
and frees dio nucrwory when no Lower yweodaol by
Lhe programs. |
|
GQ) slealie mManesxy allocation
Ci Dynonbe weanory allocation.
i Memory allocakton \-
Dy Hs | mermory pace read ed by ha. |
Vaxkaptes tn tha Progr B allocakad before.
Loading and execuling tie Prgyer-
x THO allocakad menory apace will
remain unchanged as Jong as progrem Bo conrkng
Fg). ink nome flood]
Be serous’ [ooo MaNbory “Joost Bo the
nome “home”.
Dynamic omy atlowation-
Dn Th yas memory Space reeded
by dee Vostjable allocthod duning Sho exo can
of Tha program.
Advantages Ok dynamic tmenry adlocattin over Static »
GU) Bo vhakic roennry Greate ip tow
nS
| alloca loos memory Localiows as,
Roke Nomafioo F},
“li reich cw MSM ty alwnite running Aaa ne nly hol of Hees
moy be used. The Trak 14 vnused, Re Dw
waskago of mentary.
Wi) Pj wa wank ko change
array fo ha pagan , de is powibla. by Te
editing -ua_ Program (Pk wb a Hime tonsuning
Process . |
Tn dynamic mene onecet OTS
2 Tho
labove Jewo problems wort occal bocaus
cakad duing
\
Imamory dpaco for Variables 41 489
execution |
fia Size of Ho
| Feunektomas wed To Aina te MORTTY abtto cabin". —
1) matioc CD
| 2) Catloct)
| 3). soaklocc)
| hy. Fveoc)
| ythore dunckins PO
1)| moatioc ¢3 — ANlocoHing @& block of, memory /—
x mottocC) kunckion B Used be
Allocaka: aq Umlfguows Block of Memory 2n Ryfes.
wth general focen ts ,
[potatos Vestable = (cost type*) mattoe size) |
duo hood ot flo skdiowh .
1pokae, pointer Varia gc. poinkar VorPable
blo. — Vall
Cask kype — ky pe fos poinkor robo.
ley matioct > gun oF Tre Cho eke,
mation - recggoot
size _ eoquEred size of Sue nant Pn
byes: i
MoTha above function atiecstes MOMeT of diac
ghar ing add ross of foo
of, kype cost type «
fillet wth zon
Sie and return the
|
\
[mama thrrevah painter Varrable
\
lx the | allocaked cron, £4 nok
|
| egy. @) Bae Ay >
“ge Cine se) matloc (22) 7 a
on execution % ats uncon” Ao, bytes of marory |
exe: Ctlocated and duo, acarting
lpecatc Ryko B auigned b she painbor J Of gre
addross of, tho
Jaf Gide) ME FG .
} ye Cine #) matioe (te e gizeot unk) > ,
Jon exacubion of tubs gunetign. to Himes tae se
of ob Tak Lb) lox see kykes fs atlocaked and
“fae abaakiing, address ‘op Rha Ark eye: B
lonigned so” unr jpombor Yah, KY pe tne,
|
h.
|
|® |
Block skudent
L
Ink ragno } —> si?
ai.
A yk es
ine age 5—>
Chat dox 3
Stew ;
Voi ef matol)
u
Slaton x y
X= Cok vclont ¥) mation (sire of (Student) 1;
KS
wher nmattoct)
area Stoo equal bo dua dl2e
(5 bytes) is located net “fur ararting address ef te
Bese tyke 2 ariigned ke eo poinbot Venicble, X of
dotatyp? Stuctone “—
Allocation of muttiple ‘blocks - catlectj.~
%Catlocl d functPar 2 used, kp locate,
mult’ple blocks a Conkiguerd MOMOrys «
Pt) tha blocks ae of Aone size.
The onal form Lb /
polnber \vasi able. = (Cast: kypo.*) cattecto, size), |
Pinker Yaiable — Vatte & paikar Yeuleable .
Gost — type — LyP dre poinber yokuo by Callecu3)
talloc ~ word
N-number of blocks
Bi20 ~ Tequived ize of MOMOY jn bykes
X The above funckion allocates M block monoyy
paca of size bytes:
HTKO address of ta Pirsk kyke of SHO atlocalag |
area Le retuned thrygr foo pointer Vasieeble -
THO allocated acon L filled! id 207.
Fg).
Ys Pre %) Catton ( 3 10)
On execution de’ function allocate: 3 mannry
blocks 4 gi2e 10 bykes and Fotuins sho Akanting
addvess tha atone dhrough fue pointer y
type Ine. ,
‘freet) — Releasing tea wed menoy Space /-
% freaty fund is wed go free tea
—
block. of ured MEMOrY »
FQ gy (ing ¥yMatjocCio): j
frenl yi, ' \
¥ FirAk Ababemon: Jallacakes momory space of,
Jokykes end. ~vekusn Hho Peartine address | of
Variable _
ee
ic: Allocabad. § Manmory though. He Pofnkor
44)
J: i
eTke Second ekatamonk froos tho alloca oct
MMO .
vraatioct) — Alcoring te oe ap fio block
~ ‘Teatloc ( ) funtion Bs wh ed bo. A
ho gize of The, mamoty otheacly
Ncrects e
SE det¥dao.
allocated . : /
# Tho General oven B a
Gola, = yaatloc( eld pafrleat Voi |
<3 oe
poi nbor Vank.
poe of2e)}
where, poinkot Vartable ~ Vetta co Vattode
woatloc — keyword
old poinkat vasioble. — ReM® of, poinkor Vastable.
foro size ~ sl2e of Aho new Money Aor
noodad
Eg). Yo (ine x) matloc (20) 5
oe voatloc \Y, 30) ;
stoke monk allocates Mamovy Lpaca of
% Pitak
| ize 2o bykes aud vow tho GAGA addroge
dna panko Ys ‘
yeThe ~decowd obakonork roatlorcakes ta ayreoody
A\oratad apace to 4° byscos ,Ontt-¥
File mortage mont oo
Dofining ay file -
eA fla By clefined oh FILE, WO tig
Keader pia dtotio-h
xP ffles Shout be declared O48 type
F\Ue befova ctugy ate. sad .
| °
ete generat erm 14,
|
| FILE mpoinker\routable
| whee,
Five dolkatype
pointer variable — poinkor bs dio dakaty pe
Fite
opentng a lel
% Bokora
woo toad a tile oF wd to Yo ow
Bile, we musk oper far file.
Pllc oponing Creakes fie Vint bebe
FIce % poincar vouloble 5
\ wha poble = \
pe Vartoble Soper (i pllenama! Nmode” ) ;
cone , potnker Vartaste _ ortable couboins tts
addrogs of fro type FICE
tle nome — noma of ttho lotool — any one og te0 golloirg.
ye open ta BIA fw read only
— open the fle fer conting only
@- open tte filo ter tor eppending .
at — open te Plo Ry reacting and writing
Ww - open tte Hle bw reaching and voicing |
A+ — open ta file fosv ras derP
Fg).
a FILE Ha}
as Popen("mydaka” Ne) /
>The fle mydata 2 opened kor Veo deng »
if tio file coos nok presonk oN OFT ov woil| Cc eee.
wy FILE x by
bz Lopen( best", two") 3 oa
the Fle Lest gs opened fev ‘wo8ting |
ule conkoins doko , yee it fe olalokad ard new
Atle will be creatco} . |
me the
jai FILE a ,¥by
@ = fopen ("mydaka” , ny Dy
b= fopenth tore”, Wu") 5
closing tra file:
% An opened {le must be closoct apter
Af) operations complol a. a 5
THO gorerat fom fa c oejo
‘\Pctose pointes voroela 7 |
Pius’ #a,*b y
@2fopen(nmydata 7, "¥");
| b>fopen (sket", ww"); !
Felose(ad
Felove (bys
Tnput output opaatiow on the:
O) goter) Gy puke tl)
Gi). getwcd (ivy paket)
U) fpaincget) Vb fFseantl )
Wy geke cd! -
ye De L4 used bo von ' A Arrgle. Chorackor
trom a Pla qhob het boon eperoet Gre ead mole
the seating skops oka | enol of file
Lm@oF) yoackad.
se Tha genoral form De
able)
ez goke(poinkar
woke, c variable vocedvas ho Cchotackar ,
potter Vout able — poinkey eolith .cowkosins te
addyeas ef tio FILE:GP] a shopen \wydattar, "4"!
c= gokcla) 4
colle( cc} = EOF)
L
Ppukehou le) 4
3
(iy), puee Cote
saDPk ts used bo pita a efgle Chssade 2
foo a Ble Hak bee been opened Wn conte moda.
athe gensal form Ia,
pulec (Gey, poinkosvasiable) 7
whue, © - chouadck a ke po combtden Into dua Kile
,
pol net Yout abla pointer wo
& duo FILE -
=). file *a}
haa
az topean Cvmyderta ww")
nich. concaby cia odes
| pueecx,ay >
Gif), gokwt ) '-
x TL B wad Bo yoad on Integer Yolue tuum
a file pote has boone opened fn read modo .
% The yoading Shops whan send a dile €or)ee
GSD) is veachad, pa
yt gene! a Bp
ROLLE ,
ws Fo
pointe: Vartobla - potnbar oolich conkot
addross ch to ele
EQ).
® Fila xa
We ce ;
| A 2 fopen (Nemyatata, nr?) -
| hee ee
| ~ eee
c = gekw/(ay;
whole [ oe)
PAnEE CN Yel \o” Cs
i. pao): -
yp Pk wel ko whe 27, Wnleagat Vadua
Srila a Ble hak has bean. cpened in cortte mode,
of The general ioe A,
| PukweCe, pinkevastable)* | > 1
[okare, co =)nkegat Value . 2 € Jordag
| pina vatable,. pone. whtth conkains tha—
| 4 Adetwegs A AKA FILE»
£9). :
Elacxa y
4WE
int ty
a 2 open (wmytata", Wo)
pakw i,
MITE O used t reed lata froma fle.
xethe genmal form 4,
Feceng ( point or Vatiatle , Neonkrolciing , see),]
lane inter Vostable — point ewhice conceit faa
~ address at doo Ale
contol sing — formate Commands Auch as
PN Wa rg eFO,
JEal- — Jk of Varfablos bo ba veal kre The
gle.
FD. ewe way
“ws,
Bak HY sy
2 fopen (renydakat nas, i pow
aca (a Ya 7.2", ox 24);
Wi); Fprvinegor i
x It & used ho Mite data Wo a le.eS the _ general torre bb,
Spvinkk (polntor vastablo 2 ‘ost —arantngh, BD
Lohere |
polntor Variable — polneer vo
address af te te
Cobre! Stang — pormat contnscunld Dick ad Pols Ld
| yw F eke.
| Use © tat f vastabtes to be wotbon ow tha
file.
£9), Fite #a ;
| ok UY 5
| A> Popen(Nmydaka” , wus!) :
Weel contai Ste
genekea; Mad nat", Yds
| etka Ghatomant ppinbf writes He ibe, xX are
ly a daa ile specktfed by dea potnket a
Error hendling olaeing DId opesabfor|-
xDuing Dlo operatin on exw MY
occet +
dona of fa error slsabiens oe,
1. Fryfag ko veasl beyonce io ond + fie.
a. Devite overgtowB-Tiyfng bo tie a pile uate hag nk baer, Spercsty
m an opection on O Hie,
Ie, Trying ko portor
ened for anotian tye
when to fle i op
OPaakion.
5B opening a Hil
b+ Tying to wrFte a Lon
ds stp abe Snvalia pilerame,
fo probecked file.
Evroy handling funeHowt =
Gy. feopcy — W. BeovrerO,
WI Peoged '-
¥*Pe bw
He By reached or nok.
ode the gonnst Ror a,
oe ea
» [ poop ponbor vou able)
DL ent of the ple veached , ii volun
ad tp kesk eohartrar tha ont S @
Leoro.
"9).
Bile ¥a yy
a= kopan ("mydata” ,"');
bees (a)
A |
Prine (» en of Ge!)
3—- ~e
UW) forme) \-
TE by Wed to beak a giver file dor an
evr - H
Tho general form Li,
| Berry ( Pointer V asPabie) |
&3).
8) file vay
Ak (her rov.a))
t
Pines (Nev vor"),
5
Programs:
|. |Wrfhe a program bo create ond display a file
Nanad ad “Vemploya’ Lo akora Snfesmabion Auch ag
name, age and Gala of five employers.
fneluale Kakdfo. hy
Sf nctucte Yasnio.h >
Yotd maint >
t
Fite a#pkyy
chou noe fad} »
fake ages
Yale Sabany 5
pls 2 topen (1 employer” riya) »
4gov (20; tas; dt)prinegt' |n Eneer the Kame , age pn
Seang (Wy s rd 7A", name , © *98, @ satauy) »
Ff pn ne. er, Way 4
i + Cper, v8 y.ct vd pname , ae, Catary)
tclose (pk) +,
phr am
; Fopan(Nemplloy ao”, url)»
whtle (feof (pky= 20),
De
A cadary to Nyy
al
L
fscong
pwr me N78 Yely.a”, nana , Qaga , R salosy) ;
KLLON A 8 rat Ado”, Nana “
ro", nama , age, salary) j
3
tdlose (pen 5
3
Write a prgran Jo create a file pkr ond
Oop th conkank of ply do another Atle perl,
jpjnctude
fe) nob do Lot o-h?
Void maint)
fice *pkr, xphrl 5
Chol name fan] ;
Ink 9g2 7
fre Salouy ;
Pky = fopen (Normphoyan?, tus");
. y
for (t=0 LOK By itt)@| 1
i
PrmeL (“\p Enter dae name , ogo and walary \P' 0,
Scane(ryg Yavd nama 7 EAGL , @ salasuy ) 5
FPintL (per, Ws rd Zl", mame, F927 Salar
3
AclosoC pry,
y
Pky = topen (employ eo");
Pler| = Lopen(lemploy22t?, hw!) s
Pr egtertate re)
Bech(Phe, Wyayd rd 1, navla ,Qape ,2 Salary
SPORE (BEF Vy.and yo nema , age, sgh);
ey
pelose( pv) ;
Ranclom accoss Pless-
ts dom gee ots fies ao Bly fo
WoW RO v9 oy Progrannia cow nave fha-
flo pointe, vanclomiy and clo x2ad or wr\io opkions.
Funcdon + ji
Uy Eat cy
GW). xewinde
wi) FSoale ey‘@ peat a
weThs tanccion Bs used ko webu fia, Guten
Posi os tha poinber-
w Tha genera} tore 4,
N= tbat! ( poinkar Vania
whee, fketh — keyword
wick cowkaths tho
Potabar vaabla — poitker
caddroas of dae $ile-
amore vabuae 0, voeatve. the
ni -ni
postin,
Eg), Five xpkr,
dong n>
N= Cai maneemas
@ srowindt) '
a Ths funckion used bo Fock te position
ek +a given File
of tia pointer bo du beginalg
Tha generst form “hi,
srosvind (Poincar Vast able) ;
where, rewind — keyword
Pointer — pol ater White cowsains dhe add reer
fable
Vouiab le mi Ne.®|
Fg).
cowind pity
De blac)
@| $eeekcs 1
PE Ls used Lo mve tna file pointor fo any
Aerstvod location wlinin dna pile -
| eThe genet tom L4,
48eak (pointarvariable , of eet, peel dow
|eohue, pointer Vowtable — poiater coukatns tha actA rence
| a dua Ble.
OFfsek— Bis gives tho number of posittong
ko bo moved Ann the loabimn given
in position.
Posidem - Dk ts a inkaget Dumber Position Gon
baka ony cnr of Fun pllootag Valu
© = Beginning of tha He
1 3 Gunent: position
| 2 Bed uo pile.
aes |Ne
OL, 0) —go sus. bagi Can
0) — move fo douitn by ke f
Lake fila Brome TAL pylonteg
GC | *3)- ger ( PET,
Reenk( Perry ty
Commend [ine Oagumenis t . |
ang Vina cogunanbs S4O-
3 Garten
ayguments thak ate paased Aycan Ha a
WWna2 bo 4ha main function.
ethe! gonaal fom 4,
matn (argc , xargv0I)
| ink cage - Chan’ xargvl I;
{
3 :
CouLotts Jue
ea ineagex Yartable ,
numper oh Pouamabers passed ©
; mace funckivn .
|
egy 30 array A pel ace
} Back ateang f° dats arto Cpptaitt
aha. paramekers passed 4° maip
command WHa,
ning the program
wohmne, gC —
ws bo chuacters ,
func ro
xtha. genast berm bor wr
pat ax & hia Command like
and bo give
a,C> programname Leng! , aia Z ‘59
ex ocubab|,
where, programnems — oon OT ie ean “
program
Bok ob
ezatp 4 ama
Counks 4n2 Number
vulobte. auge automatically ~ a 7
+ de
of aiguments om THO commana We on me
v ouge =LO+d.
a The pointer vaitable cugy Lakes fe
Value of oUge wa, nti as ies dive.
etna kreok location augyted veukaina a
ond locukicn
Hee prranwber progremname, ae °
SEMI! plewaga -.. SFP? —
wewheo th compan
Unkeins Hie gkering |,”
TKO third Jocabion coukains Abinge .
Thee 4,
eage - OF
GUgv DI — Program Nana
agvol- Skony |
aug viex)- SkRrg 2
aug On) = sk Bng 0&g)-
wkable Pra.
pg be fre exe
lak (sod and loves bare
THe Commenct Uae auguinese a,
— values fo pact
c>Prgrexa. God loved
The main dunwen bakes ano BY”,
matnlaige , a1gv)
ia aige , Chor Farag eI y
3
in thts cuge = 3
ang VEaT = PCF-exe— ,
ag vol > God
ougve2zd = Loves
wee a peg Js ad wo Numbers aaing Command
arguments
Hhinclucte x odio: hz
Hloctude < ebdile: h7
tp (nctuscte add to 4
hose , age -3
ego) - add
aug vd — lo
atgverd - ao
The prepwee sory >
weaoks cu
¥ DE Bb oa process Thak
source program and petorns | Som opankion on
Ze before ib 4 passes oo tha Computer.”
# The Sllowg Atovo ctiagrar> gives
Yaris Seep tye woo ting co pAogam.
DL & nok avatlable 19 many
otha Wigh level legguages.NU
SE Leming to. Program be Goropuker «
C Fan w
"_ UPreprece ates
) corapitar
© Bjeck Coola]
Jiincer
Executable Cocks
PE eparates undo ta Control pre processer
Eorormanh Une or dtyackives.
x The preprocessor directive: cue obivicad into
Abra types
x They cue,
Q) Mac Substtiat on Adrective
a). File Prcusion cttreckive—
Wily, compiler control Acrechive
Rules for wn eng Pra pwre ssov Arwoctive
of begin with tp dymbos
ti). DE soul!
a nok fended ak tre end. |
Gy. Sent cwolove
QU). only on aixeckive con® appeat on ao line.
Gv, De can appease ak OMY place ip Te Source
Coda.
(y )- Boe Cormonly Placed, before maint> sy |
belere | sae beginning ob a. Pastiurlar function,
renner reed——|
&”
|
| Macw subsatiewkhon =
| Value -
agin grey
x Pt LD used oo
wrepsosents oO
Symbol fo tha © program tote
% Dk 4 cows waits Tae WAP
Adakine pre-procedsoy ine ctives.
* Pk con be Clasitied jn&ko two
types.
ay. Simple reacy AO IneHD -
wrth ongunnonts
bb). Macro doped m
A) dimple acre dapnitien
TAR genoa Agpern La,
hue, fpcogne — Preprocessor olivecki ve.
identifier — Valid C Name
ida Vobua td Aabstured inthe
Syrnbo)—
am, sosicaad of the.
aon, progr
(dont tier.
¥PE we foctuscle Huts line to q+he
begieni ny oO ou C Program, Ane -Pre proces! ov
wepyacer every occurance Of the ickentitier in
qe Aoutca Code by the Aymbol. .
x Thue Asroud 2 ow blank betweenAre identifies and tra Aymbol.
FJ). tpdofine. VAL 200
wainc)
e
ink MCvady:
int N Evan,
3
“when we compile this Program, before te Aouad
code Passes Co dha compiler.
preprocessor Asor
jebdne Itentier vet by Bo.
* only abbor eka Pproced ue is ever, the progra>
ws passed fo po compiler:
|
utes =
Gy. Tp die Mace
do tq |clontthier os alaing .
). Fholofina COONT [00 . =, auiigns tno cbtily leo
6 ° : ‘n fo.cOONT
(iy. The gymboh “lt not . be dubskitukad deo dao
idonti He with In tte Sewing,
£g). Fedopine COUNT. loo
cefinitin te Symbol js assigned
Paine (count ")
hore coonT voll) RO®)
Git). Th tra macro caginction expres sie
can be.
foclucled as dymbols.
Fg). qeoaping A SMA 5 He MS
[Pkorap exe cor be_
GV). Dh dro race dofintdor
Inctudad as dymbols -
Eg). jPolopina TEST Bare)
Arlogina ey GoaDLoce.
Macw definition wii augunconks t-
x Macros con be olofinod orth aurguaenty |
just Lee function.
HTH general berm ia
Fp dopna idonk? Ror (A, ,93,
whee , Fpolofina — propwcessor oliveckive
| Jdontiglar— Valo © Name
{ At, Aa, + -- An gormat MACFD augumonks,
Symbol — ids \adua. La paubpsli duk ad “9 tha
formal cuppa ments. i
Eglo 4 doping CUBE(x) Ce fi
| x Th tls macs 2 catledt Jn tho program
as Volume =. CvBECIe) ;
thon tho prepmeesor expands diis ene
as Volume =Cle# (0 « lo)Le @. tf eto Pena man eee |
fine, Decrentent Fy Cycod Yelo :
c Bk Wis macro A called in dhe peegror
DECRE MENTO)!
/ ‘
bakermenk
dton dio Pprepweregscr ‘expands teu
os Akl ao) x 210
Feanctt on atgument Mace ge
eacro argument ce
fuodiun Otg uments Boa
ee
ap ne begtnaley Oe =e
eq). dptnclrcta < gkaco: hy)
jguincnende MngtKbiloneama >
———s
Ay dhe fllenena DB
ctania <> the tte
ts socacened ouly IN tie
Shondad derectorie,
BY, tno. filename £1 given
witty fro cdouio quokes,
dia file 49 Acarchod fivok
IO tho ctttrent cdtockory
enol thon sh the atat lao
Sarda dadrvoctorfes,
given
Gis). | Compiler control ivockives
yeThe dive cave db used fo cliteck Hho
Gropller bo slip & park ob Bouca tole
¥ Tha preprocessor commands, Wed A,
“Wy. Aetpctoh - - - 1. Fhenadhy
Ch). akdtop- = = 7 Helse. -- - Pendyy
WN). Bb oo Heats
WR - ele ~~ - ptonaidl
Gy) ap ihelag-- - - - fend Ab ‘ !
# Tha generat born as,
fpapcoby macrnec—
skakemont A}
| wah pacronane ars. bOoD Aogined in dae
inctucled paocter file tron Bkakenont A with be
| Compl led, — _
||
oy
Hends}
wah jhe L
ay mac HOP Li, ctaboad fo dha frctucded ble.
do dtakementt [ton will ba csmpiled ,
Hrpelag ~~ feebie -..- - fenaldl
Fpiydeh macvonane
Bkako monk Ay
hander fle eeatanerts-
ZA ith be, corpled ee St ,
£9).
gppdog MOF219 akakomane 07
folie
gkatomant A>
Skatomart fy
_ oe
X elore skokanents yton willl be conupl led 44
ole
macro Map ts dofined in na hoader file
Skatanants A te F wot be pte
. Hendtf
(ily. Hg --
The generat berm “,
Ato Abate:
conupi Jeol + ;
we Tk ne oars que swipped
Qe pay -- - --eee ent
yeThe geneuat hover LL)!Conclition_
Statement |;
Skatomont ny
Ak luo
Stato mosk fh y
‘Skakomwk &
dy end,
OR the read of dia coneliticn as peua cthen Hoe
Bkatomonks | 400 wll] be Gomptled elie sbabemeses
A ko € ull) be aowpl leaf.
—*