libft/ft_strchr.c

25 lines
1.0 KiB
C

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