Libft
42 Libft library documentation
Loading...
Searching...
No Matches
ft_strncmp.c
Go to the documentation of this file.
1
/* ************************************************************************** */
2
/* */
3
/* ::: :::::::: */
4
/* ft_strncmp.c :+: :+: :+: */
5
/* +:+ +:+ +:+ */
6
/* By: raphalme <raphalme@student.42.fr> +#+ +:+ +#+ */
7
/* +#+#+#+#+#+ +#+ */
8
/* Created: 2025/12/29 18:50:00 by raphalme #+# #+# */
9
/* Updated: 2026/04/14 10:45:22 by raphalme ### ########.fr */
10
/* */
11
/* ************************************************************************** */
12
13
#include <stdlib.h>
14
23
int
ft_strncmp
(
const
char
*s1,
const
char
*s2,
size_t
n)
24
{
25
size_t
i;
26
27
i = 0;
28
if
(n == 0)
29
return
(0);
30
while
(s1[i] && s2[i] && s1[i] == s2[i] && i < n - 1)
31
i++;
32
return
((
unsigned
char
)s1[i] - (
unsigned
char
)s2[i]);
33
}
ft_strncmp
int ft_strncmp(const char *s1, const char *s2, size_t n)
Compares two strings up to a maximum number of characters.
Definition
ft_strncmp.c:23
src
ft_strncmp.c
Generated by
1.9.8