123456789101112131415161718192021222324252627282930313233343536373839404142 |
- /* ************************************************************************** */
- /* */
- /* ::: :::::::: */
- /* ft_strstr.c :+: :+: :+: */
- /* +:+ +:+ +:+ */
- /* By: mazimi <mazimi@student.42.fr> +#+ +:+ +#+ */
- /* +#+#+#+#+#+ +#+ */
- /* Created: 2014/12/08 19:33:30 by mazimi #+# #+# */
- /* Updated: 2015/09/16 16:05:35 by mazimi ### ########.fr */
- /* */
- /* ************************************************************************** */
- #include "libft.h"
- char *ft_strstr(const char *s1, const char *s2)
- {
- int i;
- int j;
- int k;
- k = 0;
- i = 0;
- if (s2[0] == 0)
- return ((char *)s1);
- while (s1[i])
- {
- j = 0;
- if (s1[i] == s2[j])
- {
- k = i;
- while (s1[k] == s2[j] && s2[j])
- {
- k++;
- j++;
- }
- if (s2[j] == '\0')
- return ((char *)s1 + i);
- }
- i++;
- }
- return (NULL);
- }
|