-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_strcmp.c
More file actions
32 lines (29 loc) · 1.19 KB
/
ft_strcmp.c
File metadata and controls
32 lines (29 loc) · 1.19 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strcmp.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jagarcia <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/11/07 10:32:42 by jagarcia #+# #+# */
/* Updated: 2017/11/13 21:26:15 by jagarcia ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
int ft_strcmp(const char *s1, const char *s2)
{
char unsigned *s1cpy;
char unsigned *s2cpy;
int j;
s1cpy = (char unsigned *)s1;
s2cpy = (char unsigned *)s2;
j = 0;
while (s1cpy[j])
{
if (s1cpy[j] == s2cpy[j])
j++;
else
return (s1cpy[j] - s2cpy[j]);
}
return (s1cpy[j] - s2cpy[j]);
}