#include <stdio.h>
#include <string.h>
int ft_strlen(char *str)
{
int i;
i = 0;
while (str[i])
i++;
return (i);
}
char *ft_strstr(char *str, char *to_find)
{
int i;
int j;
int find_len;
i = 0;
find_len = ft_strlen(to_find);
if (find_len == 0)
return (str);
while (str[i] != '\0')
{
j = 0;
if (str[i] == to_find[j])
{
while (str[i+j] == to_find[j])
{
j++;
if (j == find_len)
return (&str[i]);
}
}
i++;
}
return (NULL);
}
int main() {
char str1[] = "i can do this all day";
char str2[] = "day";
char *a = ft_strstr(str1, str2);
printf("%s", a);
return 0;
}
To embed this project on your website, copy the following code and paste it into your website's HTML: