-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_strncmp.c
More file actions
33 lines (30 loc) · 1.15 KB
/
Copy pathft_strncmp.c
File metadata and controls
33 lines (30 loc) · 1.15 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_strncmp.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: rbetz <rbetz@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/03/28 15:16:21 by rbetz #+# #+# */
/* Updated: 2022/03/29 17:21:42 by rbetz ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
int ft_strncmp(const char *s1, const char *s2, size_t n)
{
unsigned int i;
unsigned char d;
unsigned char s;
i = 0;
d = '\0';
s = '\0';
while (i < n)
{
d = s1[i];
s = s2[i];
if (d == '\0' || d != s)
return (d - s);
i++;
}
return (d - s);
}