From a3462b7b10860f929c90170a1b590d73eb5d40e0 Mon Sep 17 00:00:00 2001 From: Tanguy MAZE Date: Sat, 7 Apr 2018 11:52:54 +0200 Subject: [PATCH] ft_striteri, ft_striter: changed int to unsigned int --- Makefile | 5 +++-- ft_striter.c | 4 ++-- ft_striteri.c | 22 ++++++++++++++++++++++ 3 files changed, 27 insertions(+), 4 deletions(-) create mode 100644 ft_striteri.c diff --git a/Makefile b/Makefile index da398f7..bc6ab2e 100644 --- a/Makefile +++ b/Makefile @@ -6,7 +6,7 @@ # By: tmaze +#+ +:+ +#+ # # +#+#+#+#+#+ +#+ # # Created: 2018/04/04 10:51:59 by tmaze #+# #+# # -# Updated: 2018/04/07 11:22:24 by tmaze ### ########.fr # +# Updated: 2018/04/07 11:42:48 by tmaze ### ########.fr # # # #******************************************************************************# @@ -50,7 +50,8 @@ SRCS = \ ft_strnew.c \ ft_strdel.c \ ft_strclr.c \ - ft_striter.c + ft_striter.c \ + ft_striteri.c OBJS = $(SRCS:.c=.o) INCLS = -I. diff --git a/ft_striter.c b/ft_striter.c index 3b4a5c6..cecf2ad 100644 --- a/ft_striter.c +++ b/ft_striter.c @@ -6,7 +6,7 @@ /* By: tmaze +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2018/04/07 11:17:26 by tmaze #+# #+# */ -/* Updated: 2018/04/07 11:20:40 by tmaze ### ########.fr */ +/* Updated: 2018/04/07 11:41:57 by tmaze ### ########.fr */ /* */ /* ************************************************************************** */ @@ -14,7 +14,7 @@ void ft_striter(char *s, void (*f)(char*)) { - int i; + unsigned int i; i = 0; while (s[i]) diff --git a/ft_striteri.c b/ft_striteri.c new file mode 100644 index 0000000..218eb6a --- /dev/null +++ b/ft_striteri.c @@ -0,0 +1,22 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_striteri.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: tmaze +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2018/04/07 11:36:12 by tmaze #+# #+# */ +/* Updated: 2018/04/07 11:48:32 by tmaze ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "libft.h" + +void ft_striteri(char *s, void (*f)(unsigned int, char*)) +{ + unsigned int i; + + i = -1; + while (s[++i]) + (*f)(i, &s[i]); +}