UPDATE
I have rewritten the code to get rid of allocating memory inside strstr, as advised by ratchet freak and Jerry Coffin.
char *my_strstr(const char *haystack, const char *needle)
{
size_t needle_len;
needle_len = strlen(needle);
while (*haystack)
{
if (*haystack == *needle)
{
if (!strncmp(haystack, needle, needle_len))
return ((char *)haystack);
}
haystack++;
}
return (NULL);
}