From 475449dd4b1f3308bac6f72c34d87812216a0738 Mon Sep 17 00:00:00 2001 From: Charles Date: Wed, 24 Jul 2019 18:57:19 +0200 Subject: exam02 --- exam02/rendu/ft_strrev/ft_strrev.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100755 exam02/rendu/ft_strrev/ft_strrev.c (limited to 'exam02/rendu/ft_strrev') diff --git a/exam02/rendu/ft_strrev/ft_strrev.c b/exam02/rendu/ft_strrev/ft_strrev.c new file mode 100755 index 0000000..c58bc25 --- /dev/null +++ b/exam02/rendu/ft_strrev/ft_strrev.c @@ -0,0 +1,33 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_strrev.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: exam +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2019/07/19 17:08:38 by exam #+# #+# */ +/* Updated: 2019/07/19 17:18:13 by exam ### ########.fr */ +/* */ +/* ************************************************************************** */ + +char *ft_strrev(char *str) +{ + int i; + int j; + char tmp; + + i = 0; + j = 0; + while (str[j]) + j++; + j--; + while (i < j) + { + tmp = str[i]; + str[i] = str[j]; + str[j] = tmp; + j--; + i++; + } + return (str); +} -- cgit