From 264ae2f047a53ffac92271e4609038d17605738e Mon Sep 17 00:00:00 2001 From: Charles Date: Fri, 26 Jul 2019 23:17:36 +0200 Subject: exam final --- exam_final/rendu/ord_alphlong/helper.c | 52 ++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100755 exam_final/rendu/ord_alphlong/helper.c (limited to 'exam_final/rendu/ord_alphlong/helper.c') diff --git a/exam_final/rendu/ord_alphlong/helper.c b/exam_final/rendu/ord_alphlong/helper.c new file mode 100755 index 0000000..7d285c1 --- /dev/null +++ b/exam_final/rendu/ord_alphlong/helper.c @@ -0,0 +1,52 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* helper.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: exam +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2019/07/26 14:40:48 by exam #+# #+# */ +/* Updated: 2019/07/26 16:35:08 by exam ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include +#include +#include "include.h" + +int ft_strlen(char *str) +{ + int counter; + + counter = 0; + while (str[counter]) + counter++; + return (counter); +} + +int letter_diff(char a, char b) +{ + if (b >= 'A' && b <= 'Z') + b += 'a' - 'A'; + if (a >= 'A' && a <= 'Z') + a += 'a' - 'A'; + return (a - b); +} + +void ft_putstr(char *str) +{ + while (*str) + write(1, str++, 1); +} + +int str_lettercmp(char *s1, char *s2) +{ + if (ft_strlen(s1) != ft_strlen(s2)) + return (-1); + while (*s1 && *s2 && letter_diff(*s1, *s2) == 0) + { + s1++; + s2++; + } + return (letter_diff(*s1, *s2)); +} -- cgit