#include <stdio.h>


char *ft_strstr(char *str, char *to_find)
{
    int i;
    while (*str)
    {
        i = 0;
        while (str[i] != '\0' && str[i] == to_find[i])
        {
            i++;
        }
        if (str[i] == '\0')
        {
            return str;
        }
        str++;
    }
    return NULL;
}
int main() {
       char *string1 = "needle in a haystack efl.bjewj.f";
   char *string2 = "haystack";
   char *result;
 
   result = ft_strstr(string1,string2);
   
   /* Result = a pointer to "haystack" */
   printf("%s\n", result);
}

Embed on website

To embed this program on your website, copy the following code and paste it into your website's HTML: