aboutsummaryrefslogtreecommitdiff
path: root/exam_final/rendu/ord_alphlong/helper.c
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/ord_alphlong/helper.c
parent475449dd4b1f3308bac6f72c34d87812216a0738 (diff)
downloadpiscine-8ec5431354bdb582455e8c32758098c5a0fdada2.tar.gz
piscine-8ec5431354bdb582455e8c32758098c5a0fdada2.tar.bz2
piscine-8ec5431354bdb582455e8c32758098c5a0fdada2.zip
exam final
Diffstat (limited to 'exam_final/rendu/ord_alphlong/helper.c')
-rwxr-xr-xexam_final/rendu/ord_alphlong/helper.c52
1 files changed, 52 insertions, 0 deletions
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 <marvin@42.fr> +#+ +:+ +#+ */
+/* +#+#+#+#+#+ +#+ */
+/* Created: 2019/07/26 14:40:48 by exam #+# #+# */
+/* Updated: 2019/07/26 16:35:08 by exam ### ########.fr */
+/* */
+/* ************************************************************************** */
+
+#include <stdlib.h>
+#include <unistd.h>
+#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));
+}