base c lib without external lib
This commit is contained in:
22
ft_strncmp.c
Normal file
22
ft_strncmp.c
Normal file
@@ -0,0 +1,22 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_strncmp.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: dgaillet <dgaillet@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/11/05 17:34:15 by dgaillet #+# #+# */
|
||||
/* Updated: 2025/11/05 17:41:35 by dgaillet ### ########lyon.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "libft.h"
|
||||
|
||||
int ft_strncmp(const char *s1, const char *s2, size_t n)
|
||||
{
|
||||
if (n <= 0)
|
||||
return (0);
|
||||
if (*s1 != *s2)
|
||||
return (*s1 - *s2);
|
||||
return (ft_strncmp(s1 + 1, s2 + 1, n - 1));
|
||||
}
|
||||
Reference in New Issue
Block a user