-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathft_compare_results.c
executable file
·52 lines (46 loc) · 1.67 KB
/
ft_compare_results.c
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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_compare_results.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ysoroko <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/11/28 19:51:29 by ysoroko #+# #+# */
/* Updated: 2020/11/28 19:51:29 by ysoroko ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft.h"
int ft_strcmp(const char *s1, const char *s2)
{
int i;
i = 0;
if (s1 == 0 && s2 == 0)
return (0);
if (s1 == 0 && s2 != 0)
return (-1);
if (s1 != 0 && s2 == 0)
return (-1);
while (s1[i] != '\0' && s2[i] != '\0' && s1[i] == s2[i])
{
i++;
}
return (s1[i] - s2[i]);
}
int ft_compare_results(char **your_str_tab, char **good_str_tab)
{
int i;
i = 0;
if (your_str_tab == 0 && good_str_tab == 0)
return (0);
if (your_str_tab == 0 && good_str_tab != 0)
return (-1);
if (your_str_tab != 0 && good_str_tab == 0)
return (-1);
while (your_str_tab[i] != 0 && good_str_tab[i] != 0)
{
if (ft_strcmp(your_str_tab[i], good_str_tab[i]) != 0)
return (-1);
i++;
}
return (ft_strcmp(your_str_tab[i], good_str_tab[i]));
}