/*
char	*ft_strstr(char *str, char *to_find)
{
	int	i;
	int	j;

	if (to_find[0] == '\0')
		return (str);
	i = 0;
	while (str[i])
	{
		j = 0;
		while ((str[i + j] == to_find[j]) && str[i + j])
		{
			j++;
			if (to_find[j] == '\0')
				return (&str[i]);          
		}
		i++;
	}
	return (0);
}
*/
// a paufiner
char    *ft_strstr(char *str, char *to_find)
{
    int i;
    int j;

    if (to_find[0] == '\0')
        return (str);
    i = 0;
    while (str[i])
    {
        j = -1;
        while ((str[i + (++j)] == to_find[j]) && str[i + j])
            if (to_find[j] == '\0')
                return (&str[i]);
        i++;
    }
    return (0);
}


#include <stdio.h>
#include <string.h>
int main(void)
{
	char str[] = "Rugby Top 14"; //chaine principale fullString dans la quelle on va faire la compariason
 	char to_find[] = "Top"; // sous chaine substring la sous chaine a rechercher

 	printf("%s\n", ft_strstr(str, to_find)); 
    printf("%s\n", strstr(str, to_find)); // retour 
    return (0);
}

Embed on website

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