libft
Loading...
Searching...
No Matches
ft_strncmp.c
Go to the documentation of this file.
1
/* ************************************************************************** */
2
/* */
3
/* ::: :::::::: */
4
/* ft_strncmp.c :+: :+: :+: */
5
/* +:+ +:+ +:+ */
6
/* By: tspoof <tspoof@student.hive.fi> +#+ +:+ +#+ */
7
/* +#+#+#+#+#+ +#+ */
8
/* Created: 2022/10/31 13:47:38 by tspoof #+# #+# */
9
/* Updated: 2022/11/09 18:56:01 by tspoof ### ########.fr */
10
/* */
11
/* ************************************************************************** */
12
13
#include "
libft.h
"
14
15
int
ft_strncmp
(
const
char
*s1,
const
char
*s2,
size_t
n)
16
{
17
size_t
i;
18
19
i = 0;
20
while
(i < n && (s1[i] !=
'\0'
|| s2[i] !=
'\0'
))
21
{
22
if
((
unsigned
char
)s1[i] != (
unsigned
char
)s2[i])
23
{
24
return
((
unsigned
char
)s1[i] - (
unsigned
char
)s2[i]);
25
}
26
i++;
27
}
28
return
(0);
29
}
ft_strncmp
int ft_strncmp(const char *s1, const char *s2, size_t n)
String compare.
Definition
ft_strncmp.c:15
libft.h
src
ft_strncmp.c
Generated by
1.9.7