| 1234567891011121314151617181920212223242526272829303132333435363738 |
- /* ************************************************************************** */
- /* */
- /* ::: :::::::: */
- /* ft_strstr.c :+: :+: :+: */
- /* +:+ +:+ +:+ */
- /* By: bchanot <bchanot@students.42.fr> +#+ +:+ +#+ */
- /* +#+#+#+#+#+ +#+ */
- /* Created: 2015/11/23 16:41:28 by bchanot #+# #+# */
- /* Updated: 2018/10/13 22:51:57 by bchanot ### ########.fr */
- /* */
- /* ************************************************************************** */
- #include "libft.h"
- char *ft_strstr(const char *s1, const char *s2)
- {
- size_t size;
- size_t i;
- size_t j;
- i = 0;
- j = 0;
- size = ft_strlen(s2);
- if (size == 0)
- return ((char *)s1);
- while (s1[i])
- {
- while (s2[j] == s1[i + j])
- {
- if (j == size - 1)
- return ((char *)&s1[i]);
- j++;
- }
- j = 0;
- i++;
- }
- return (NULL);
- }
|