blob: 7d285c1a6686a10a4309a89d4e95cd6343083727 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
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));
}
|