protected strchr & strlen

This commit is contained in:
Tanguy MAZE
2018-05-16 16:10:34 +02:00
parent c5a13918c2
commit 491de12723
3 changed files with 13 additions and 10 deletions

View File

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