I am trying to check if a string is a sub-string of another string. I have wrote my code so that the big string is compared with the smaller strings, so that i can find out if the smaller strings are sub-strings of the big string. But when i try to run my code, its acting wrong and not taking input as it's supposed to.i think it might be printf problem. But Don't know what the actual problem is. Any help is highly appreciated.
Here's a link to the problem i am trying to solve: https://onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=18&page=show_problem&problem=1620
#include<stdio.h>
#include<string.h>
int main()
{
int k,i,j,l,m;
scanf("%d ",&k);
for(i = 1; i <= k; i++)
{
char S[100001];
int q;
fgets(S,100000,stdin);
scanf("%d",&q);
char T[q][1000];
for(j = 0; j < q; j++)
{
fgets(T[j],999,stdin);
for(m = 0,l = 0; m < strlen(T[j]);)
{
if(l >= strlen(S))
{
printf("n\n");
fflush(stdout);
break;
}
if(S[l] == T[j][m])
{
if(m == (strlen(T[j]) - 1))
{
printf("y\n");
fflush(stdout);
break;
}
m++;
l++;
}
else
{
l++;
m = 0;
}
}
}
}
return 0;
}