for school, I have to recreate the strstr function. I did, and I tested it as much as I could, and everything seems to work perfectly.
I am still looking into it but after several hours of troubleshooting, I don't get it. Can someone tell me what's wrong with it compared to strstr ?
char *ft_strstr(char *str, char *to_find)
{
int i;
int k;
i = 0;
k = 0;
if (*to_find == 0)
return (str);
while (str[i] != 0)
{
while (str[i] == to_find[k])
{
i++;
k++;
if (to_find[k] == 0)
return (&str[i - k]);
}
i++;
k = 0;
}
return (0);
}
Should I include a main for testing ?
Thank you.
EDIT : Here is the error code of the machine :
> $> ./0z09k44vyodiwxihua4w30m9 $> diff -U 3 user_output_test1
> test1.output | cat -e
> --- user_output_test1 2021-08-11 17:55:47.000000000 +0000$
> +++ test1.output 2021-08-11 17:55:47.000000000 +0000$ @@ -2,7 +2,7 @@$ 0$ -1$ 0$
> -7$
> +-1$ 0$ 2$ 2$ @@ -12,7 +12,7 @@$ -1$ -1$ -1$
> -87$
> +-1$ -1$ -1$ -1$
>
> Diff KO :( Grade: 0