aboutsummaryrefslogtreecommitdiff
path: root/exam_final/rendu/ft_strrev
diff options
context:
space:
mode:
authorCharles <sircharlesaze@gmail.com>2019-07-26 23:17:36 +0200
committerCharles <sircharlesaze@gmail.com>2019-07-26 23:17:36 +0200
commit8ec5431354bdb582455e8c32758098c5a0fdada2 (patch)
tree480c68814f822439850029df0e0249a2cafb8177 /exam_final/rendu/ft_strrev
parent475449dd4b1f3308bac6f72c34d87812216a0738 (diff)
downloadpiscine-8ec5431354bdb582455e8c32758098c5a0fdada2.tar.gz
piscine-8ec5431354bdb582455e8c32758098c5a0fdada2.tar.bz2
piscine-8ec5431354bdb582455e8c32758098c5a0fdada2.zip
exam final
Diffstat (limited to 'exam_final/rendu/ft_strrev')
-rwxr-xr-xexam_final/rendu/ft_strrev/ft_strrev.c40
1 files changed, 40 insertions, 0 deletions
diff --git a/exam_final/rendu/ft_strrev/ft_strrev.c b/exam_final/rendu/ft_strrev/ft_strrev.c
new file mode 100755
index 0000000..685dd70
--- /dev/null
+++ b/exam_final/rendu/ft_strrev/ft_strrev.c
@@ -0,0 +1,40 @@
+/* ************************************************************************** */
+/* */
+/* ::: :::::::: */
+/* ft_strrev.c :+: :+: :+: */
+/* +:+ +:+ +:+ */
+/* By: exam <marvin@42.fr> +#+ +:+ +#+ */
+/* +#+#+#+#+#+ +#+ */
+/* Created: 2019/07/26 10:34:13 by exam #+# #+# */
+/* Updated: 2019/07/26 10:40:13 by exam ### ########.fr */
+/* */
+/* ************************************************************************** */
+
+int ft_strlen(char *str)
+{
+ int counter;
+
+ counter = 0;
+ while (str[counter])
+ counter++;
+ return (counter);
+}
+
+char *ft_strrev(char *str)
+{
+ int i;
+ int j;
+ char tmp;
+
+ i = 0;
+ j = ft_strlen(str) - 1;
+ while (i < j)
+ {
+ tmp = str[i];
+ str[i] = str[j];
+ str[j] = tmp;
+ i++;
+ j--;
+ }
+ return (str);
+}