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

String

Uploaded by

sumukhanayak025
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

String

Uploaded by

sumukhanayak025
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

#include<stdio.

h>
#include<stdlib.h>
char str[50],pat[20],rep[20], ans[50];
int i=0,j=0,c=0,k=0,m=0,flag=0;
void strin()
{
while (str[c]!='\0')
{
if (str[m]==pat[i])
{
m++,i++;
if (pat[i]=='\0')
{
flag=1;
for (k = 0; rep[k]!='\0'; k++,j++)
ans[j]=rep[k];
c=m;
i=0;
}
}
else
{
ans[j]=str[c];
c++,j++;
m=c;
i=0;
}
}
ans[j]='\0';
}
int main()
{
printf("eneter main string\n");
gets(str);
printf("eneter patern string\n");
gets(pat);
printf("eneter repalce string\n");
gets(rep);
strin();
printf("eneter final string\n%s",ans);
}

You might also like