-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_strncmp.c
29 lines (26 loc) · 1.19 KB
/
ft_strncmp.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strncmp.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: hkrifa <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/03/23 09:37:20 by hkrifa #+# #+# */
/* Updated: 2021/04/05 11:09:12 by hkrifa ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
int ft_strncmp(const char *dest, const char *src, size_t n)
{
size_t i;
unsigned char *d;
unsigned char *s;
i = 0;
d = (unsigned char *)dest;
s = (unsigned char *)src;
if (n == 0)
return (0);
while (s[i] == d[i] && s[i] != '\0' && d[i] != '\0' && i < (n - 1))
i++;
return (d[i] - s[i]);
}