-
Notifications
You must be signed in to change notification settings - Fork 1
/
ft_strncmp.c
executable file
·26 lines (24 loc) · 1.11 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strncmp.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: rel-fila <rel-fila@student.1337.ma> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/10/16 13:40:01 by rel-fila #+# #+# */
/* Updated: 2022/10/18 22:40:37 by rel-fila ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
int ft_strncmp(const char *s1, const char *s2, size_t n)
{
while ((*s1 != '\0' || *s2 != '\0') && n > 0)
{
if (*s1 != *s2)
return ((unsigned char)*s1 - (unsigned char)*s2);
s1++;
s2++;
n--;
}
return (0);
}