/*
C PROGRAM FOR FINDING THE SUBSTRING */
#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
char str[10],sstr[10];
int m1,m2,i,j,temp;
clrscr();
printf("\n\t\t FINDING THE SUBSTRING");
printf("\n\t\t ~~~~~~~~~~~~~~~~~~~~~~");
printf("\n Enter the string:");
scanf("%s",str);
printf("\n Enter the substring:");
scanf("%s",sstr);
m1=strlen(str);
m2=strlen(sstr);
j=0;
for(i=0;i<=m1;i++)
{
if(str[i]==sstr[j])
j++;
else
j=0;
if(j==m2)
temp=0;
}
if(temp==0)
printf("\nThe string is found:");
else
printf("\nThe string is not found:");
getch();
}
OUTPUT:
FINDING THE SUBSTRING
~~~~~~~~~~~~~~~~~~~~~~
Enter the string: GOODMORNING
Enter the substring: GOOD
The string is found.
0 comments:
Post a Comment