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

String

The document provides examples of using character arrays to store strings in C programming. It shows initializing character arrays with string values and using printf, puts and scanf functions to output or input the strings. The examples demonstrate how to declare, initialize and print strings from character arrays.
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)
12 views

String

The document provides examples of using character arrays to store strings in C programming. It shows initializing character arrays with string values and using printf, puts and scanf functions to output or input the strings. The examples demonstrate how to declare, initialize and print strings from character arrays.
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/ 11

STrina

Stmang is a seasinse of a chomacto that is o teat


teast %
Sanqle deta teom.
Dioleahong Lnitil2ation Yannable.
atex- Chan Stwonamame oSizel
Ex@mple
Chan et 2oI
nitiizátion Cnpik time)
Chan
cit = oVzdkorasyan Univetit 3
x - Rn ime
Chn et C3
preintfEnte a stnat
Sonf("ZS", it)>
Ow.a c. p to find the 1enjth ofthe string
tincude/stdio. k
tincudel
sonio h9
HincudeStriAh>
Noid main C)

Cn int n; Chan p 201,


printf"Ente a stvanF") ,

scanf C S", P)
me Rstrlen (P);

pantfThe lenght of Strinds = %4', n)'


eteh Co
D 8 12: 2 0 2 f- 35

Srin limar Fumetion|

s t r l e n C) ind the 1ergkt ofa strin2


Small latte
Gi) StrLwr C) t o Convenf a stminn
>revense o rang.
a String Capeta S Lett
iv) struprO Conven
Ome Atringinto amothezs
to op
(Y) Stvcmp C Com pare &ranA the
8tring at the; ed o
t o ahappe apperd
one
vii) St cat ()
notenAtrs1 stnan ah e
Vystn e.at ( > ts append 4st nd chaneetu o-a
of the anothen trung
ithout m e j d g the-
Cas
S Cmpa U C o m p a n e two atring
(19o chanaete of two smaT
Stnemp ) Compae 1st n

(xi)stnneP) to opa stm chaneeten a 6triT nto ano4

to find the
le ngt o t h e smis witout sing strlenC
Ow.a. e.p
Aun etion
Hineludalstdio. h>
Aineudel Comio. h
Noid main)

nt i; Chan p [3

p intf Enter. the Atring *


Sccnf (%S P
i0
hle CP tia =g*o)3

pointf (The Lenght of thestring d )


aetehc
Dt . 12.21

11)
a a P
c p to Counta no of-vowel and m

Csana
CanseLen san In put Vidhtasagan Unvn c
¥nelude stdie.h
Hinetude <cenio. hy
incde stnant h
Noid main (()

itco, va0, i,n chan p 3o1,7AdT


prantf( Ente the
Sstrann ")
Seanf C" 1Sy P)
Stera P)

ti ="0')
N V-+1

se

printf"Numben of vowe= % d", v


print Numben of
asatn
ouspiut 4 );
aeeuC)

Home omR.
ate > 24.12: 202 P-37
DWrite a e preram to ChecK a st is palLndOme. not

include<stdio. h
Hincude <conio. h?
tincludestri ng. h
Noid. main C)

Chan p [30, y[3o7,Y


pminf CEnte -he sti ):
Scanf C%S", P
Str cP
Stev O O
if Cp»
2
pnintfLs is a palindreme stri7, aP)

elSe
palindrome 8ug "PE
printfZS a's a net

getch C
S
Ci) Strlen Fun etion C
Sytex Stwlen ( StminA nAme
patatPe Vanabename. =

EX Chan a C201;
intb Stwlen Ca)
neam
*tneude<stdd.h
ineudeLeono. h
+ incudeksmith
void main
Chan a [ 3 ° ,
int
peintf CErten a bstran: ' )
Scanf S a)
b S t r i e n (@);

printfC Thlenghtefret string s %d", b)


tehe

O) Stept funetion C
Syntex StrePt ( Destination tmsng, sSon.ce stwan

Hinclude<stdioh>

Hineudeconas. h
ineludekstnin h>
No matn
R b E3o7
han a 30I,
mint Enten a seunc Btran
scanf (7S a)
pointfCEnte a dozbinaken n i n a
Saanf C S b);
Sytocet (b, a)
printf (The cos atrats %8", s)
Aeth C)
Dt-2A.122o2
P33
Ci) stncp Fun etion
ntex_: eteneF (Testènatiem&tnána, sour.ce stvan-n)
Ex
tineludestdia.
#ineudeKConio. h
t me.lude Kstrama>
void ain C)

Chn a3o1, b T3 o
prsnf(" Enta- a stming )
SCant (%3, a),
prantf (Enten 2ud stana P
a

Soanf ( b)
StwnepM (ba,3 ce1-'
prantf The coP traaa as %', ) ,
aetch C,

Civ stmcat Fumion C)


S e x Strcat (Destinction string Sounce Stra ;
Ex
incledestdno k
inakuadeceonco.h
tinciose/stwaá
veid main C)
2
poidf (Eten á destinati on r i n t
Seanf(as, ),
Patt Enten oa eowee o

S-tr eat a, b),


Pnt The Con cadsnate Smana-
etchD

dettnatton an Ram
Emte S nce D
The Concadddaate mo4
RamDA
(V) Stmmca Fuwrnctien
S r n c a t (De«tianation tmnt, Soun eeSTa
Ex atnaete o
inelude <stdib. h
neude gsnio. h AnottheastY
neadesrath
No ld main C)

Sea a C3o Hallo


clua bt3o1 Gnod Menniny
stncat (a, b, 4 );_ a C = '\0'
g e t CS

(YI) Stemp Funetuisn

Note-Oi the deffenence s eqal to 0, then


iststman 2wd t a n
If+the defenenee iS posatve, tHen

1the deffenenee as negatie the


t string 2nd snag
$ta p i n t a strep (1st string 2d strina).
A- 2 65-
incud/stdio.h 2-9-/22
ineludeKeonio. h
incudetman
Notd mainC)
Cum a[301, bl3°],

printf ("Ente two 21ring",


ScafCsIA, a, b),
Stm emp (, b))

printf C Stran ah ooua)


etse if (do)
on f I s t rin eatetha 2sdt
Dt 21.122021
-39
Nii) sonemp incticn
Smtex ashncmp (string 1, sming2n)s
tineude Ksddo. k
4tinthude Cstmina:
Noid main C)

CnaC3o, bC301
intd
Prantf " Ete tw str ")
Scanf C"rsy.s a, b);
Stncmp (G, b, 3)3
f (d--o)
mintf Ea stmang ,
e s e if (4 d> o)
Pnintf isamina s reatethan 2u4 stao

Pnsntf2ud atmaint s .atedtar 4stAtrgD,

(Nii) i e y faneion

amex Stmne (StmanA name

ineadestdio.h>
tineudestnan >
Yoid mtinC)

Chan oa C3°1,

Pantf E t a a t i m a )
Seanf S ) a);
Stnne (a),
p antf ( Revenc minq is S )

3
22o 2-1| P-40

Strempi fmetson
Syrex in = stmoem pi (1 ststm 2mdSm
AA Ine.lude3tdio, n
aidmaln d-strempi (a b
intd
Chan aCs), bT3)
Poantef(" Eten minqd ne mp meta
Se
A
"7 a, b)
CseseNse[oe

Strempi(a, b);
iC4o)
printt C" Two SAna as
Same),
ppantf(" notSame

Dt-O4. O1.2022

ex incude 4stdio.h
4include <conie. h>
void main ) )

chan aDo-'M,r,'D,'N; "A)P, D°R, 'E ' S


int,
i i o ; ik=6 , i*) OutputH
Pmanf ("SC arii);
MIDNR-PO
etek C

.Ex:2 a [to] 2'M',i,4, 'n','a', °p', '0', *r', e,


-

3
in

Pitf ( I , atiT);
ouput
actchC)

Midnapore
D+ D4 01.202.2 P
Ex3
Chan ati *m°,* 1 D, N 'A',P; '0', 'R','E,°\
printf(ZS",a) -Outpu
M MDAPoRE

Ex-4
3'M','',d, n, 'a', p: o, ' m
Chan ati
tou pu4
puts (a)s
Midna pr

Ex-S

chan ao]="Midnapore Out pu


pusts ( , Mdnapme

Ex tout pu
Ohan aUlo EntenStr
printf ("Enten Stminst: N u JD
Scanf % S", a),
puts (a) ; NwL

does notaltew for he-


Spaee
scan fun ction.

incude <stdio.h eu put


4#include Aconio. h Ente Stwing: Nun JP
void main C)
N D

Chan a Cio1
prantf( Enten Stran )
Seamf ("4s a)
uts a
th ,
D-o4. O1 2o22 P-42

hinclude<stdio:h Y Disple
4ineude Kconio. n S T
STU
4tincudestrina:
Noid main C). STU D
STUD
lmscmC)
Chan a C 1- STUD",
in i , ,
L Stheen (ay;
foi0 i{-L; i+t)
fo(j-o, jK: i j++)
pmintf (ZC", a tj1);
pnindf CY°n"

You might also like