-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathft_strcmp.c
31 lines (28 loc) · 1.15 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
31
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strcmp.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: psprawka <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/07/04 12:04:03 by psprawka #+# #+# */
/* Updated: 2018/06/22 02:23:56 by psprawka ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
int ft_strcmp(char *s1, char *s2)
{
int i;
i = 0;
if (!s1 && !s2)
return (0);
if (!s1 || !s2)
return (1);
while (s1[i] || s2[i])
{
if ((s1[i] < s2[i]) || (s1[i] > s2[i]))
return ((unsigned char)s1[i] - (unsigned char)s2[i]);
i++;
}
return (0);
}