Untitled

mail@pastecode.io avatarunknown
plain_text
2 months ago
487 B
1
Indexable
Never
char	*ft_strstr(char *str, char *to_find)
{
	int	i;
	int	j;

	i = 0;
	j = 0;
	if (to_find[0] == 0)
		return (str);
	while (str[i] != 0)
	{
		j = 0;
		while (str[i + j] == to_find[j] && str[i + j] != 0)
		{
			if (to_find[j + 1] == 0)
				return (&str[i]);
			j++;
		}
		i++;
	}
	return (0);
}
#include <stdio.h>

int main()
{
	char str[] = "Pompam";
	char to_find[] = "a";
	
	printf("ft_strstr: %s",ft_strstr(str,to_find));
	printf("\nstrstr: %s\n",  strstr(str,to_find));
	return (0);
}