wip_parsing
This commit is contained in:
27
libft/str/ft_strncmp.c
Normal file
27
libft/str/ft_strncmp.c
Normal file
@ -0,0 +1,27 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_strncmp.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: madumerg <madumerg@student.42angouleme. +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/10/30 16:12:37 by madumerg #+# #+# */
|
||||
/* Updated: 2024/03/29 11:43:32 by madumerg ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "libft.h"
|
||||
|
||||
int ft_strncmp(const char *s1, const char *s2, size_t n)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
i = 0;
|
||||
while ((s1[i] != '\0' || s2[i] != '\0') && i < n)
|
||||
{
|
||||
if (s1[i] != s2[i])
|
||||
return ((unsigned char)s1[i] - (unsigned char)s2[i]);
|
||||
i++;
|
||||
}
|
||||
return (0);
|
||||
}
|
Reference in New Issue
Block a user