-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_strcmp.c
More file actions
33 lines (30 loc) · 1.24 KB
/
Copy pathft_strcmp.c
File metadata and controls
33 lines (30 loc) · 1.24 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strcmp.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: gdannay <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/11/09 19:43:57 by gdannay #+# #+# */
/* Updated: 2018/01/07 16:54:12 by gdannay ### ########.fr */
/* */
/* ************************************************************************** */
#include <string.h>
int ft_strcmp(const char *s1, const char *s2)
{
size_t i;
unsigned char *c1;
unsigned char *c2;
i = 0;
c1 = (unsigned char *)s1;
c2 = (unsigned char *)s2;
if (!(s1) && !(s2))
return (0);
if (!(c1))
return (-c2[0]);
if (!(c2))
return (c1[0]);
while (c1[i] != '\0' && c2[i] != '\0' && c1[i] == c2[i])
i++;
return (c1[i] - c2[i]);
}