mirror of
https://github.com/Ladebeze66/libft.git
synced 2025-12-13 04:36:55 +01:00
30 lines
1.1 KiB
C
Executable File
30 lines
1.1 KiB
C
Executable File
/* ************************************************************************** */
|
|
/* */
|
|
/* ::: :::::::: */
|
|
/* ft_strncmp.c :+: :+: :+: */
|
|
/* +:+ +:+ +:+ */
|
|
/* By: fgras-ca <marvin@42.fr> +#+ +:+ +#+ */
|
|
/* +#+#+#+#+#+ +#+ */
|
|
/* Created: 2023/02/09 17:12:38 by fgras-ca #+# #+# */
|
|
/* Updated: 2023/02/14 13:26:15 by fgras-ca ### ########.fr */
|
|
/* */
|
|
/* ************************************************************************** */
|
|
|
|
#include "libft.h"
|
|
|
|
int ft_strncmp(const char *s1, const char *s2, size_t n)
|
|
{
|
|
size_t i;
|
|
|
|
i = 0;
|
|
if (n == 0)
|
|
{
|
|
return (0);
|
|
}
|
|
while (s1[i] == s2[i] && (s1[i] != '\0' || s2[i] != '\0') && i < (n - 1))
|
|
{
|
|
i++;
|
|
}
|
|
return ((unsigned char)s1[i] - (unsigned char)s2[i]);
|
|
}
|