ft_strchr: correcting pointer return

This commit is contained in:
Tanguy MAZE 2018-04-05 10:37:24 +02:00
parent 698a37b399
commit 62d185463c

View File

@ -6,7 +6,7 @@
/* By: tmaze <marvin@42.fr> +#+ +:+ +#+ */ /* By: tmaze <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2018/04/04 18:54:17 by tmaze #+# #+# */ /* Created: 2018/04/04 18:54:17 by tmaze #+# #+# */
/* Updated: 2018/04/04 19:15:12 by tmaze ### ########.fr */ /* Updated: 2018/04/05 10:25:13 by tmaze ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -15,10 +15,12 @@
char *ft_strchr(const char *s, int c) char *ft_strchr(const char *s, int c)
{ {
int i; int i;
char *tmp;
i = -1; i = -1;
while (++i == 0 || s[i - 1]) tmp = (char*)s;
if (s[i] == c) while (++i == 0 || tmp[i - 1])
return (strdup(&s[i])); if (tmp[i] == c)
return (&tmp[i]);
return (NULL); return (NULL);
} }