/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_strnchr.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: tmaze +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2018/05/16 11:41:02 by tmaze #+# #+# */ /* Updated: 2018/05/16 11:56:15 by tmaze ### ########.fr */ /* */ /* ************************************************************************** */ #include #include "libft.h" char *ft_strnchr(const char *s, int c, int n) { int i; char *tmp; i = -1; tmp = (char*)s; while ((++i == 0 || tmp[i - 1]) && n > 0 && i < n) { printf("loop %d\nc: %c\ntmp[i]: %c\n", i, c, tmp[i]); if (tmp[i] == c) return (&tmp[i]); } return (NULL); }