0% found this document useful (0 votes)
32 views

Sthlen, STHLWN), Sthuph, Stheat), Stmeatt), Sthepha: 53.wte Down The Unctions O The Foloin Stelj Relaked

The document discusses various string manipulation functions in C language like strlen(), strlwr(), strcat() etc. It explains what each function does, its syntax and provides examples of using each function. It also discusses memory allocation functions like malloc(), calloc() and free() as well as differences between structures and unions.

Uploaded by

ankan2881
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
32 views

Sthlen, STHLWN), Sthuph, Stheat), Stmeatt), Sthepha: 53.wte Down The Unctions O The Foloin Stelj Relaked

The document discusses various string manipulation functions in C language like strlen(), strlwr(), strcat() etc. It explains what each function does, its syntax and provides examples of using each function. It also discusses memory allocation functions like malloc(), calloc() and free() as well as differences between structures and unions.

Uploaded by

ankan2881
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 20

PAGE: 18

DATE O5/01 /24

The taed fumeion lets) is used 40 inut mut


Scan)can also be used to Qeeert mJai whd Skg bã
wbiting it in the fodoina mameh
Soanx[An]s, A);
53.wte down the unctions O the foloin Stelj relaked

>sthlen,sthlwn),Sthuph,stheat),stmeatt), sthePHA
StCn), Stheoi0, stCh,sthhev).
Sthlen)’His ashind redated dibka Auncticn used
to Pind ahe deest of a stmt. Hehe stei is
fassed as an auement
Foh CrmPleimt
d=Sthlenl"B00do)
Heke the out Put oP the Code wil be =6,
wn0>IS used t0 Con V¡hh a slang netm UPPer Case
to dowe ease, Tt takes wa alsguoments,ibst
is the destination and Seeond is the Souhee.
ahenamPAe:- Sthlwbl31, 32);
Hebe the dower ase stbimt of $2 ih be Stored in 81,
shuekIt is uSed t6 Covabla sthing Phom Aowe
is the destimati¡n nd Second is he Sahce.
Fok examplei thuPh(34,32);o t
Hche the uPe, case. stringoP.s2 ih be stoked in S1
PAGE:
DATE: 05/0/24|

atPehd ome SAbm oSthm


istcatl5Ttis atherUsed to. sAid.T+takes
end o Sbimtwd be
ahuements.The seeordhe ilest stbin
as Hhe endP
added to
Fob Cxaomei SHcat(S1,32); to the end oP S2
be added
Hebe he stm m s2wì
dpend Sst 1n'chbecteh
Sthcat()5 TtIs used tofo Sthim to the end oP Pimd
Ahe Second ist 2
Sthind.Tt-takes and 4he 3hd
aguments are sint
ahtuments is aniegevalue.
5Chokecleh a sog s2 wu be cded
Heke the Pist
Ao 4he end o S1,

Steinas.
Shmt T4 4okeg o obt0nents a
Hele lst 8bjng s 4he destinatlom ana
Second Stbns the souree, oissi
Foh ExanPle stteePs1,32);.
Hele the Sthimt hom $2, wi he coPied mto the Sthinn

StkenPI0s used to ComPahe twÌ Stbings.I4S


etubhns. eitheh 'o' Chehu'seit bettbns
noneko vaduesiin Ahis Case stbs ake
Consideked wa ease Sensitvitt.

Hehe,hD Stbins 81 aond $2 ahe Comaieed wlh


PAGE: 20
DATE O5/01/24

ease.shivitdTE Hhed ahe evua then the value of'x


hwil be '0 otheIse theNadue oE X wid be aont nom
Zerovaue.
stenPi)’It iS USed to Comdle to Sthinds.1t takes o
I thetns eithel 'o
Steimgs as aluonets.
or man-zeho vaue.It doeS COnsidek he Case
Sensitivitd oP the stbints.
oaPle- ntaj
n=SthenP(s1,S2);
Hebe, nO Sthmas S1 and 82 ahe Comaibed with each.obhek
ithout eensiderin& Case. Sensitiyitd.If S1 0od 82 ahe
both eual Hen hen he Value ' i l be'o' ohehwise

he vadue of be non-eko.
Shche)’It is uSed to find the Pibst oceuhhence oP
a iven Chakecteh ina sejmS. It hetlns
the fositon oP the Choeecteh n the sthim.
Tt takeg wo abuoment, fiSt one iso sthina
Qnd 2nd cneisthe chahaetehAo be. foundim
the Stend
Foh enonPAe :- mt
A= AhehhlS1,a);
Heke 'siis Ahe iven Stbingand he ehahecteh hesents
in the Vobiables a wh be sekched in the Ste 81. As
Saon as he iyen Charecteh is.faund ok the Pihst me,
t wceetun 4he fostion- t0 Ahe Nobiable,
stthev)tis used to kevehse aavem Sitang. Tt Eutes
two abguments,fibs Ghes he destination
sthimt aohd. Secord One isthe Soulkee stima
PAGE:
DATE:05/01/1,|

souweeidd be eNehsed and


the
The Sthina imdestincion
in the Sthina.
Stohe
FokexamPle-stbhev(84,32);
heset in Ahe S2w he hevekse
Hehe,the stm
and Stoked mthe en 31.
Tates oP Anallec),calloc),red)
5B. He down Uhe
RAonctionP
MaldoC)-> It is use k dinonie memok aloenticn
allocotes memolet Bpomhe heoP The
H whehe 3omthim
heoP is an ahea of memo
is Stobed.
Maloc allocates memoeoP a eeuested Site ahd
betubns a Pointek t he beagnn o he alloeated
block
2The Satan O mallocis as followsi
iidPointeh aeiable =(datat r ) malloe(onuombeh oP
Fob rale-To aJocate memobd Por lo 1mtete
tATe elements Ne Can use madoe) funchon aS
Ifows.

colloct) Aealloe) funeticn is a TEedefimed


lanibaba fneion hat StândS fob Gotucus
memobd alloetion I4is used to Qreate
Sphciz Phoom havina Hhes Sané sizé mthe memo
PAGE: 22
|DATE O5/012

mte,v-iable
<datattre:)Callocourbek OP blcekS,.
sizeofblock); bloek the
ketubnS the base addbess of the fibst
Tt
Pointeh vahiable
Qldocate memckt oh ointee e
Fob eraPleTo
elementS we Can use Caldoe() Fonctiãn
as klloS.
=(nt)aloelo, sizeofint);
Feel)- It 0S USed to beeasethe ddnagie omemobt
ob onoJdoel)
which is ollocated bd etheh ealloe Glbe
Auocion These alocated omemobi Pheed
to theih OWn,Qnd So we hNe to reised he memob i
bd using fhee) Luneion explicitA.
The Sätax is as folowsia
Pree(Tointeh tPe abiable)
Fo- CxamPle Fee();

55. weite down the difakence betneen Colloc)and omaloe


Calloe Malloce)
5DTiS funcicmn that assiârs9ris a Raontien that Chentes
a sfeeified nuombeh of blaeks one block dffaemoiht of a Frel!
oP memced to asinâle nolbable size.
It takes two ahfments that i TA akes ont akeaument
is numbeh of bloeks and bloek n the fobm muombeh o elements
Sze. * size d each of elements.
Deaoe is loweh than Smalloct)DMaloec) lsfhstek han calloelO.
all,nolekS1,mak82; imt
student AhucFoexánPle
Stueuhe
Cim deteen Ao
USedKeokd, issthuct
a Hehe
vobiables; Xedota
Sthuctube Stkct
folloNS deeleaeA
ds be
Steucube
ean A
soctuhe
in?e decjeara Ghu wìl Hok 51.
oelton nemcht ContiloUS Stoked
im ahe whichelementS,
ofdisivilae
dota RndS eadution
oP ASthuctuke ais
StueueP 56.hat
is
ero. omemoh
to the
itiotized dose Maldec iniadited
the eaee
lePPicienc4.
ieieneh time Aow Dealloe)
has
has
time hih Maloe)
MalAloeO
E:06/01/24
23PAGE:
PAGE: 24
DATE:O6/01/24

58.Nieh cehatel: is colled as g4setue mnenbek oteesS.

>stheuetwe membeh aceess ofehatokis Q9 OPehatoh tused


o aceess tHe membehof a sthuctuee.Dotl) is Called
as stueube,membeh QCeess oPelhatoh fob an ohdinab
Sthuctuhe vabhioble.In Case offomteh Stucthe Vaeioble
the membeh aceess dPekotob is()Sed.

59.Neite dokn he useS of Shuctuhe.

Dehanim the Size oP ewbsok.


DCleabina the Contents of the seheen,
Pleasind the eubsSch at an aPhoPeiate Position on Seheem.
>Dhawin and thaPhics Shafe on the Seheen.
Reeeivind the ket Pronm 4he keboakd.
60. leite down the dPPehene between FeinieL)Qnd SPhintf).
PhntPO SPhintPO
The TbmtOPuneicn
brimates An sbites out PA tolemates an stoké a. Sieice of
the sthandaei out Put SAheam haractebs Cnd values in he
Stdout, gkont abatt Pointed to bi bußgel.

61.weltedolin the diPehenee betweeD Seanf)ad SsCanP).


>Senn() >Sean heads Phem he Sthahdehed im Put
Stheoom Stdin
PAGE: L3
DATE:0{/0124|

SseAnPU->SscanPO beads Phom Ahe chabacteh


Stbimd.
62.|hat isPileP
AFle isadohcal Contoimeh.rt haJds diefahent
data elemets im0n ohâani zed fom.
63. wha ae the veHous Ofeolcns that CAn be Coteiet

hehe ahe diPehent oPshati g Ahat


Qon be cad out

i)DOPenint and existint le


Reodind Phom aeile
|)Movim to a SPeciEie loeatlon
)weitimt to a Piue. imaeile(seekKna).
tstvielosnaaie.
>'FILEis
alfavebioas
an in buil
Sthúctute nC.T Gontents
îmsktent
we WOont to infobmat.ion keAabdiond ac Pile he
|Akst oPod weeafom
have to
Cehtainoktions wheneveh
kelated ale,
to
Cheate a
FILE' Stbuctke. hbouah this Poimtek tife vebialble o
)io oK CReni hcAd, Tointe tafvehioble Ne
wbte,eOeh ood Closé a le
52 2h0or,92-)H
PAGE 26
|DATE \0 /01/24|

65.Mht is 4he Pulfbse dP Poen()ineP


len()is a. liblakd unetion. It is used t6 ofem an
eistima file,Tt takes to auomentS viz.Nome of the
de and node of the e.

6.what is the use Fieteo funchon jac R


he Faeteo Puneion is sed to head the Comtains. ofa
Sile ehabecteh wise. Tt means 1 Gan head and betun a
Sindle Chaeectek ata time
67.ho s'EoF'P
>|EOFmeans emd of Ple malkek. Itis an in built naco
dened mthe Pile "stio.h, he AsCII Yalue Of this
omacois 26.
68.hot alze teoubles im ofennd a file?
>The ve kious thOubles imoPenin& a Pile are
>File is mot Phesent.
Fle mat be CokaPted.
ip File mai cbe not ofemed dewto msucient memolet
SPace.
DMemo omat be im white Protected mode.
69.hd fclosec).umction s used m@P
>elosecO function is used An close a le which is allheadt
oRened. Thbee oPebations ake Pelbemed hile elcsimt a
PAGE: 24
DATE:10/0124|

Ale usna felose).


woLdd be weitten
Chahacles n 4he buefek
D The
to the PilemAhe dsk. chabeetek with AseII VlUe
DAA the Cnd of aPle a
lsstEot) Oud et wbitten.eliminated fhom memolb.
The bufe ould be
ofenna modes ime?
0. hat ake the vebotus Eile
oPen a
|The foldowim ahe the vebious nodes to
le:
OPened suseessfula
p " tSaheh aRle.If he is Pointeh
and setS UPa
i into memoet
fofer) doads the it.Tf he Ale
to RNs chakoctehin
bhich foints ketuns'NuLThhoutn
COnmat be ofened fofen
this mode we eam kead Pomm he Pile.
DW>I eabches the Sle.Tf the Pe exists tS
COntents albe ovebbten.tAhe le dosenot
exist a ew le is cected.T ketunSNuL,
to wYte now ContentS to a é ,

a tSeobeles the: le. Tø he fle iS ofened


i)
Suceessfalt Rofegnldoads t nto memakt
And setg Pa Phjonteh that Polmts to he dast
chakecteks in it, T the Pide dose met exist, a
inew file is keated. TS bebns NuL! R
unable o oPem Pile.TtAs used to add new
PAGE: 28
DATE:1o /o1 /24

Contents at the dof the Rle.

i It Sealches the file.TP is oPened SucessfuAWa fr)


Jcads it into memoed AordSets uPa Pointeh which Point
to the Abst chahecteh mit.Its ketuwen'NUL'Iuh
to oPen the File.The vekious of ekat 1onsPossible ahe
headm existinContets, wetina mew Gontents,
modt existina ontents of4he Pile.
w4Tt Seorches the Pile.T tte file exists,its eontents
ake ovewetten. I? the Fide dose not eist a mew
fle eheated.Retukns'NuLL tunable tooen the
Ale. The Nerious oferation Tossableae
wbitin new eontents,keadin hen bacK ond modiot
eistina Cotets oP the le,
Na+"’T Seaehes Ahe le I he le is ofened
Suecessfua fofentO doods it into memole and
3ets uP afhatek which Toint& to the st
Chabectek imit?he de does not eist,a new
Ale is eheoted, ReAums'NuLPunable to OPem
the Pile, The veouS oferation Fossible ahe
eeading eistin Cotents,oending meN @ontonts
to the end of lecanot modif eoustmt ContentS.
71.nbot is ethe use of Pe) inep
-5 The RAcOis a daibeok funcionü sed to wite into a Ale
chaecteh wise.It meansit Can hite ne Chabecte ata
ime. It takes odment bi~.A chahectet and aPoimte
PAGE: 29
DATE:16 IO1/2

72.Whatis the stbin Phem


head the
Used ao fiSt
>PAASECO fonetiomiS kes S3al-umens Hhe is he
a sPeeiRed Ple.It CLtt, Second
akjunent
is ahgunent is the
Sa sthind hich hibd
stbind Qnd the
lenh of he
ETLEtfe Poimtek.
RAsehseoOf SPlet ) in e?
73. What is he
the Stb nto
used to wlbite
Te PPuteofuoctiom'sauoments-1ibst one is he
the Ale,Tt takes
ito the Ple and Secomd ne ig
Sthn to be wetên which Pits to he Pile mtwhic,
the FILEt Toirek
SAbimwoLld be wbilen.
between Pbin4R)and Peimtk
what is 4he diPfehernce
h
’PemtPO Puncion is used to displat the eontentS waite
monitok ; Wheheas PPRint) Punetiom s used go
he Contentsin ecod Bm to a Rle.
P P tPES akomets as stbngs,dPPekemt bnat
SPee^Piebs ánd vebiablés: whekeas PPlentf) Pes
ahument as FILE APe Foimteb, foknat SFeeifieks aond
vabiables.
75.hot ishe di2Pehenee belween SConP and

>SeonfO Punctiom ìs used to et datá Prom


PAGE: 30
DATE 16/01/24

Keabont:wheheas fseoorf() is used te eod cata Prem


a Ple.
sCan) takesthe ahunents Such as fekmat steeeks
lond hefeherce of ahiables; whekeah fcanf) takes
a-uoment Such aS FILE re Poimtek hmat seeies
and eference of yebables.
16.ete dobnthe dilekence between ieat Ple and binab
es ne?
le
Tet fde Bnaat Ele
J Theten les can be easila bBimabt fe Gooot eAsily be
ohe GomPuteh
tbansFeked from one ComPteb AamsPeked From
sastem to ahcthek sastem to aonotheh due to
NabationS in the teenal
vahiatlonS in he ntehnal
kePhesentaticn uhich vabicus
on IPkom ComPuteh to Contek.
pt Stobes data usint ASCTTi) Tt SokeS dota mbnaet
emtie. huomn eadable oamat i.e. eombingion oP o's
ShaPhie ehahacieks. and i'S.

Thes Ales cheate fohtabiltd d hese Bles alke n3ilt


Poblem Pobtable.
Tent Ales wll 4ake much)Binad eoltake
memoed SPace. memobt Sace loss Comaleed
PAGE: 31
DATE:16 /0| /21,

Binakt ele
Text Rile Ehobin bimohdile
imate4 Ple an be Ple and o
PErheh leobhus the
asita heeotizedLaondelimina
i Jasideteted.
ted.

AeodOme?
Rahat is the Puboge of
head data Phom ai
Pheod) fneois used used o takes the ahtaments.
lon kecohd based manneb, Tt oPoferato,
befehence ofasthucue Noable,Sim Fomter.
oembek oP beods 0nd'tIE' 4N1e

2Sbte) funetion is used o wee contents mtoQ


Ede in a kecobd bo8ed mooneb, Tt akes abtuments
Such as a beehenee ofa StkUCtwke vabigbde, 8ie of

>Enumekation ath enuon in e is a sfeeial Kimd Of dota


Lare defned bt the useh.T Consistsof ConStent
ntehals Qn 1nteebs hat ahe iven n0m@g bt a
useh. The Use oP enum ine to naome the ntageh
values onakes the entihe PhothoÝn east o.Jean
undestand aond naimtain b the 3ame n ENen
99072
PAGE 32
DATE 17 /01/24

80. Nie down the shtaa O ehuen Paive Qn eacole.


> n enon is defmed b usmd he 'enuom' ketbohà im e
lland the use oFa Comma''
efakateg the conStats
thin, The basie stontaxodeinint on enunis
enuom enumhome

int GomSt1,imt const 2.,nt Const3,.t Gonsth


3;
Tn he aboe Stntax the defat vaue of the nt Gohst
s o, 1nt Gonst2 is 1,nt Gonst3 0S 2 and So ahtoeve
Ne CAn also Chonde tis defaut Nalues while deelain the
enum. Tor examPke
enum cabs

BMW,Fehhabi, ee, Rande Rove, Meroedes Ben


3
81. whot is umon jne?
>The union is a user defined data e ne that Con
Contain elements f that dedigerance dota 4Tes
Sust SABOctie, But untKe SthuetkeS,all he
membehS of the unionahe Stohdim heSaome memokt
eationto this, onldone meambeh Can Stke data
aa the iven imstoenGe.

datatre membeh 1i
PAGE: 33
DATE:14/l/2

doto4e omembeh 2

Fob xaomle’

Chach d4;

82. wbite dowm 4he diPRehenee between Sttuettre 0nd

SAhuetuhe U'niom
The Ketapkd SteuctS The kesokd union ìs.
used to dePne astuctire, luged to deine atni¡n.
when a vakiable is a8soe-when a vaable 1s
aed wttha stkucte, a ag8ocited wth a uonion, the
leonle aJdoateg he the
omPileh aldoentes:
memoed Poh ench membeb, memop bd Considebing the
SieOESthuctuke s ual Sie of 4he dahest memoht.
othe Sum oP sies oP ES SO Sieof tuoaion is eNuad to
bnembeb&. he Site oP kabest oMembek.

Ench membeh wihin as |i Metmobt alloeated is shalked


sthuctehe s assitned uniue bà individal meinbebs of
stohade akea oP Joeation.umon.
PAGE:
|DATE

Ahucure Union
>Akenating the vadue ofal> AJAenati the value of an
amemteb wid not abbout loP the member wild ateh
nembehsoP4he
lotheh oheh membeh vadues.
sthucture.
sevekad membehs oP
a n i the kst membe)h oPa
stbuctwe coon imitialize at lunioncomn be imitiaized.
omce.

Tndividual megmbeh eAn bev) Ond one membek ean be


accessed ata me. aceessed at a time.

83.whd 8e is caked as anid- Jee danuage P


>is Con8ideked as a mid-devek latuage becOLSe it
SuPDAs he Fetuies OP bth dow Jeye aoá hì-h level
Aaonduates,C Janguate Poakacm is Convelded into a8semibly
ie,As SEOHS Pointeh a-ithemeiedow leye), but it is
nachene indePandeot latst Ratue o hih Jevels p

84.Use of#inelude imePhohamonind


ne ude is a wad oP ineludind a standahd ok useh
tdefmed Pein the Phoghaem ad is onosla wolten at the
Pee-Phoeessek diteetiein e It is heod bt the The-Thoee
-Soh aord mstbuct 1Ao inse+ he Gorentk sfaUseh
defned oh S1Stem heodeh fie in aePhoeam
PAGE: 35
DATE: 19/02/24|

ncde
Polews 0nede(sdlos)
the Content oP Sidio.hLas

l Conuteks Plima omemolt?


we make a Ancom eathe elkaomiteks.
whe eveh imomEmabt
heun oddhess et Boked at a Ploee
Hand he esUoUnd when he
Enewn as a 3tockhe Sta@k
duan
Conthel hetubnsAromhe l e Aunctien.nuS
akewOking th a.
evekd heVhsive Anelten all we
Aesh set oP PeramitehS.
Also note hat. while weiina leeeubsive
FonchanNe mis have 0n iP sAtement Scmewhehe
function t0
in the beeubsive Auonehiez to Rohee heexected.IP
keun ithot keeusive .! being
n 0n indefmite loP and the StackA KeeP on
settnPled th Tehamieks and Ahe ketukn
FAadabeg eoch time Hhekeis a call.the Sack wDuJd

tme ebheh indeatng that he Sack haS becrome All


86.whots the siaifconee o de SuonGnt ntt)
vod Suonlint c, int )-3ìiPies hat sum s a
Aafunchion, hauimt oetintPe vod.It meang it does
PAGE: 36
DATE: 20/01 /24

87. what do tou omeanbSeofe oPa Naiable P


>me Scof of a vakiableim e is Ahe bloek on the begionin te
phoaom whe a Valiable is declieh, defined Qond uSed.et4st
lotside he beion, we Coonot acCess the valeable 0nd it s
aheated asuodeclehed jdentiBek
88. ee do the advotadeslad diaodvoontogeS Go Switeh
Cose

Adyetadesi
ItCnhahGES Gode beAdablitt ad olioni~ah¡n
Aable.
p T+ Smtle Pie, CoPlen nested i-else.

Tt on SuTbkt indeteband ehabectk dalaties..


dcases Cao fau 4hheugh if at Aalninded mith a bheak
89. whot is ahe PAfbie af ghetubn statement
the
>The lowm ahe PuPaSe of hetbm 8tement
hp the betuen Staeomet mad ch mat not laetukn a
02/24| Thoblem..
34 Pholkagn?
Shaed
heit
PAGE:
DATE: ine&e.
aat
Pixed
bi ad
and
a ofomemoktise PhototieS
modiulabity
n
ahadsdmebs
oP is
hot PlebSle
nte heaAe
of uonchcn
Phegmetint,
imebiHhe im wegtae
oP use
akestaaielock li
he ollowin to
heeg
ghat haye Phevidin
dec,lel-ation,
Abais ve8e.
ahe DIm aNe
e T code,
90.
hha leode
1.

You might also like