UtilLib
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_strncmp.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: yantoine <yantoine@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/11/11 08:46:16 by yantoine #+# #+# */
|
||||
/* Updated: 2024/10/25 21:47:18 by yantoine ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "libft.h"
|
||||
|
||||
int ft_strncmp(const char *s1, const char *s2, size_t n)
|
||||
{
|
||||
size_t index;
|
||||
|
||||
index = 0;
|
||||
while (s1[index] && s2[index] && index < n)
|
||||
{
|
||||
if (*(s1 + index) != *(s2 + index))
|
||||
return (*(s1 + index) - *(s2 + index));
|
||||
index++;
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
Reference in New Issue
Block a user