#include<stdio.h>
#include<string.h>
int main()
{
char a[100], b[100];
int i, j, n, m, k, c;
printf("Enter A String : ");
gets(a);
printf("Enter A Sub-String : ");
gets(b);
n = strlen(a);
m = strlen(b);
for(i=0; i<n; i++)
{
k = i;
c = 0;
for(j=0; j<m; j++)
{
if(a[k] == b[j])
{
k++;
c++;
}
else
break;
}
if(c == m)
{
printf("\nSub-String is found\n\n");
break;
}
}
if(c != m)
{
printf("\nSub-String is not found\n\n");
}
return 0;
}
#include<string.h>
int main()
{
char a[100], b[100];
int i, j, n, m, k, c;
printf("Enter A String : ");
gets(a);
printf("Enter A Sub-String : ");
gets(b);
n = strlen(a);
m = strlen(b);
for(i=0; i<n; i++)
{
k = i;
c = 0;
for(j=0; j<m; j++)
{
if(a[k] == b[j])
{
k++;
c++;
}
else
break;
}
if(c == m)
{
printf("\nSub-String is found\n\n");
break;
}
}
if(c != m)
{
printf("\nSub-String is not found\n\n");
}
return 0;
}
Comments
Post a Comment