#include <stdio.h>
int length(char *str)
{
int index;
index = 0;
while (str[index] != '\0')
{
index++;
}
return (index);
}
char *ft_strstr(char *str, char *to_find)
{
int index = 0;
char string[length(to_find)];
while (str[index] != '\0')
{
if ((str[index] - to_find[index]) == 0 && index < length(to_find))
{
return to_find;
}
index++;
}
}
int main() {
printf("aaa %s\n", ft_strstr("needle in a haystack","haystack"));
return 0;
}
To embed this program on your website, copy the following code and paste it into your website's HTML: