diff options
Diffstat (limited to '')
-rw-r--r-- | libft/src/ft_strchr.c | 33 |
1 files changed, 17 insertions, 16 deletions
diff --git a/libft/src/ft_strchr.c b/libft/src/ft_strchr.c index 40dcd0f..1f2e745 100644 --- a/libft/src/ft_strchr.c +++ b/libft/src/ft_strchr.c @@ -1,14 +1,13 @@ /* ************************************************************************** */ -/* LE - / */ -/* / */ -/* ft_strchr.c .:: .:/ . .:: */ -/* +:+:+ +: +: +:+:+ */ -/* By: rbousset <marvin@le-101.fr> +:+ +: +: +:+ */ -/* #+# #+ #+ #+# */ -/* Created: 2019/10/07 18:39:17 by rbousset #+# ## ## #+# */ -/* Updated: 2019/10/13 08:36:43 by rbousset ### #+. /#+ ###.fr */ -/* / */ -/* / */ +/* */ +/* ::: :::::::: */ +/* ft_strchr.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: rbousset <marvin@42.fr> +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/02/14 17:07:07 by rbousset #+# #+# */ +/* Updated: 2020/02/14 17:07:07 by rbousset ### ########lyon.fr */ +/* */ /* ************************************************************************** */ #include <stddef.h> @@ -16,14 +15,16 @@ char *ft_strchr(const char *s, int c) { - size_t i; + char ch; - i = 0; - while (s[i] != c) + ch = (char)c; + while (s) { - if (!s[i]) + if (*s == ch) + return ((char *)s); + if (*s == '\0') return (NULL); - i++; + s++; } - return ((char*)&s[i]); + return (NULL); } |