I have corrected the code:
#include<stdio.h>
#include<string.h>
int main ()
{
char str[100], sub[50], *p;
int i, len;
setbuf(stdout, NULL);
printf("Give a Sequence:");
gets(str);
printf("The Sequence u want:");
gets(sub);
len = strlen(sub);
printf("len=%d",len);
do
{
p = strstr (str, sub);
if (p==0)
{
char temp[50]={0}; // declare and initialze in loop
printf("sub=%s\n",sub);
strncpy (temp,sub,--len);
strcpy (sub, temp);
}
}while(p==0);
printf ("The biggest sequence is:");
printf("%s",sub);
}
The temp[50] you are using must be cleared every time the loop runs and use p==0 instead of p=='\0' as it causes segmentation fault