ft_strchr: correcting pointer return
This commit is contained in:
parent
698a37b399
commit
62d185463c
10
ft_strchr.c
10
ft_strchr.c
@ -6,7 +6,7 @@
|
||||
/* By: tmaze <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* 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)
|
||||
{
|
||||
int i;
|
||||
char *tmp;
|
||||
|
||||
i = -1;
|
||||
while (++i == 0 || s[i - 1])
|
||||
if (s[i] == c)
|
||||
return (strdup(&s[i]));
|
||||
tmp = (char*)s;
|
||||
while (++i == 0 || tmp[i - 1])
|
||||
if (tmp[i] == c)
|
||||
return (&tmp[i]);
|
||||
return (NULL);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user