char *ft_strstr(char *str, char *to_find)
{
int i;
int j;
i = 0;
if (to_find[0] == '\0')
return (str);
while (str[i] != '\0')
{
j = 0;
while (str[i + j] != '\0' && str[i + j] == to_find[j])
{
if (to_find[j + 1] == '\0')
return (&str[i]);
++j;
}
++i;
}
return (0);
}
#include <stdio.h>
int main(void)
{
char sfull[] = "Rugby Top 14 ?";
char s2[] = "Rugby";
char ssub[] = "Rug";
printf("%s\n", ft_strstr(sfull, ssub));
}
To embed this project on your website, copy the following code and paste it into your website's HTML: