-
Notifications
You must be signed in to change notification settings - Fork 1
/
ft_strcmp.c
30 lines (27 loc) · 1.18 KB
/
ft_strcmp.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strcmp.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: oadhesiv <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/04/20 18:52:36 by oadhesiv #+# #+# */
/* Updated: 2019/06/01 15:54:09 by oadhesiv ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
int ft_strcmp(const char *s1, const char *s2)
{
size_t s1_len;
size_t s2_len;
size_t cmp_len;
if (!s1 || !s2)
return (0);
s1_len = ft_strlen(s1) + 1;
s2_len = ft_strlen(s2) + 1;
if (s1_len > s2_len)
cmp_len = s2_len;
else
cmp_len = s1_len;
return (ft_memcmp(s1, s2, cmp_len));
}