-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_strcmp.c
More file actions
36 lines (33 loc) · 1.27 KB
/
ft_strcmp.c
File metadata and controls
36 lines (33 loc) · 1.27 KB
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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strcmp.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: lpetsoan <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/05/20 14:48:17 by lpetsoan #+# #+# */
/* Updated: 2019/06/21 08:31:33 by lpetsoan ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
int ft_strcmp(const char *s1, const char *s2)
{
int size_1;
int size_2;
size_1 = ft_strlen(s1);
size_2 = ft_strlen(s2);
if (size_1 == 0 || size_2 == 0)
return (size_1 - size_2);
if (size_1 < size_2)
return (size_1 - size_2);
else if (size_2 < size_1)
return (size_1 - size_2);
while (*s1 && *s2)
{
if (*s1 != *s2)
return (*s1 - *s2);
s1++;
s2++;
}
return (0);
}