summaryrefslogtreecommitdiffstats
path: root/libft/src/ft_strchr.c
diff options
context:
space:
mode:
authorJozanLeClerc <bousset.rudy@gmail.com>2020-04-19 22:27:11 +0200
committerJozanLeClerc <bousset.rudy@gmail.com>2020-04-19 22:27:11 +0200
commit62afe606a355581c5b48cca361478c43fb6ae4cf (patch)
treea278fe2fdf44c296892616554743b9d380ff7afa /libft/src/ft_strchr.c
parentAdded joe-sh_history to gitignore (diff)
download42-minishell-62afe606a355581c5b48cca361478c43fb6ae4cf.tar.gz
42-minishell-62afe606a355581c5b48cca361478c43fb6ae4cf.tar.bz2
42-minishell-62afe606a355581c5b48cca361478c43fb6ae4cf.tar.xz
42-minishell-62afe606a355581c5b48cca361478c43fb6ae4cf.tar.zst
42-minishell-62afe606a355581c5b48cca361478c43fb6ae4cf.zip
Well well well that wasn't too bad, now remake everything
Diffstat (limited to 'libft/src/ft_strchr.c')
-rw-r--r--libft/src/ft_strchr.c33
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);
}