Files
aoc/2024/14/libft/ft_strcmp.c

35 lines
1.2 KiB
C
Executable File

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strncmp.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: tomoron <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/07/15 21:47:47 by tomoron #+# #+# */
/* Updated: 2023/12/03 17:06:39 by tomoron ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
int ft_strncmp(const char *s1, const char *s2, size_t n)
{
unsigned int i;
i = 0;
if (!n)
return (0);
while (s1[i] == s2[i] && s1[i] && i < n - 1)
i++;
return ((unsigned char)s1[i] - (unsigned char)s2[i]);
}
int ft_strcmp(char *s1, char *s2)
{
int i;
i = 0;
while (s1[i] == s2[i] && s1[i])
i++;
return (s1[i] - s2[i]);
}