Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

C Program for Pattern Matching, Lab Reports of Computer Science

The code for a c program designed for pattern matching. The program reads input text from a file and searches for a given pattern in it. The pattern is defined as a string 'aaba' in this specific implementation.

Typology: Lab Reports

2020/2021

Uploaded on 12/21/2022

vishwajittidke
vishwajittidke 🇮🇳

5 documents

1 / 2

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Pro
actical
No.
Dote:
G//22
Am:
Write
o
prognam
or
Patfenn
Motchicg
5oftuaoe
Requiod
ova
Online
Cormpile
Prognom_Code
include<stdio.h>
Einclude<slring.
h>
void
se
anch
(Chan
po,
chan
txt)
in
M=strle
n(pal)
nt
N
stnlen
(+xt)
fon
Cint
70
1<=
N-
M,
++)
on
(j-
o,
js
m i++)
f
(t
+57-po
)
break
tpninlf
CPottenn
found
o
index
od
Nn
int
main
)
chan
xt
AABAACAADAABAAA BAA":
Chon
po+
AABA
5onth
pat,
t x t
et
unn
O
3
Oulpu
Patlenn
found
a
ndex
O
Poenn
found
at
index
9
Paltenn
found
ot
ndex
13
Conclusíon
Patttnn
Matehing
ets
yau
ongonize
he
code
as
matehin
9 patdtn ns
to
be
exetued
tuhenthe
pat4en
maieh
is
found
pf2

Partial preview of the text

Download C Program for Pattern Matching and more Lab Reports Computer Science in PDF only on Docsity!

Pro actical No. Dote: G//

Am: Write o prognam or Patfenn Motchicg

5oftuaoe Requiod ova Online Cormpile

Prognom_Code

include<stdio.h>

Einclude<slring. h>

void se anch (Chan po, chan txt)

in M=strle n(pal)

nt N^ stnlen (+xt)

fonCint 70 1<= N- M, ++)

on (j- o, js m^ i++)

f (t +57-po )

break

tpninlf CPottenn found o index od Nn

int main ) chan xt AABAACAADAABAAA BAA": Chon po+ AABA 5onth pat, t x t et unn O

Oulpu

Patlenn found a ndex O Poenn found at index 9 Paltenn (^) found ot (^) ndex (^13)

Conclusíon Patttnn Matehing ets yau ongonize he

matehin code^ as

9 patdtn ns to be exetued tuhenthe

maieh is found pat4en

cASSMAte Date:6I22Page: Pracico No. 1

Aim: WNeite a pnogeam fon Pateno Matchiag-

50fHuuaoe Requioed Tava Onliae Compilen.

Pnoqeam Code iecudecstdio.b includesstníag.h vaid scancb^ (^ chan^ pot^ chan^ *fxt.

int ME Stnlea Cpat), int N=6tnlen(txt fon Lint i=o i=N-M:it tatS fon i0, jkM,jt) iiftxtri+ i1=pat )

break

priatECCPatiro ound at index od \n D

iat main) char *xtAABAACAADAARAAA BAA

chan pat=AABA

SeanchLpattxt peuna

Output: Patlena ound at iodex o

Patkennfound ot iodtx Patten aunol atedex 13 Conclu6lan Pa no Matchinq lets uo angaoize the cad as metehin9 patlenns tbeexecukd when the

paffenn mateh is found.