first commit
This commit is contained in:
27
ended/C03/ex01/ft_strncmp.c
Normal file
27
ended/C03/ex01/ft_strncmp.c
Normal file
@ -0,0 +1,27 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_strncmp.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: ajoly <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/07/21 10:14:08 by ajoly #+# #+# */
|
||||
/* Updated: 2022/07/21 10:14:11 by ajoly ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
int ft_strncmp(char *s1, char *s2, unsigned int n)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
i = 0;
|
||||
if (n == 0)
|
||||
{
|
||||
return (0);
|
||||
}
|
||||
while (s1[i] == s2[i] && i + 1 < n && s1[i] != '\0' && s2[i] != '\0')
|
||||
{
|
||||
i++;
|
||||
}
|
||||
return (s1[i] - s2[i]);
|
||||
}
|
Reference in New Issue
Block a user