This is strstr() function made by me as given in the practice problem.
char *cstrstr(char s[],char ss[])
{
int l1,l2,i,j,k,flag=0;
char *p=NULL;
l1=strlen(s);
l2=strlen(ss);
for(i=0;i<l1;i++)
{
//cout<<"i:"<<i;
p=&s[i];
if(ss[0]==s[i])
{
for(k=i,j=0;j<l2;j++,k++)
{
//cout<<"j:"<<j<<"k:"<<k;
if(ss[j]==s[k])
{
flag=1;
continue;
}
else
{
flag=0;
break;
}
}
}
if(flag)
return p;
}
return NULL;
}
Plz verify it. Any suggestions,comment or recommendations are welcomed.
[I'm between a beginner and a pro in c++]