init
This commit is contained in:
29
Correction/dfdgdf/ex01/ft_strncmp.c
Normal file
29
Correction/dfdgdf/ex01/ft_strncmp.c
Normal file
@ -0,0 +1,29 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_strncmp.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: jmendez <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/07/20 14:58:04 by jmendez #+# #+# */
|
||||
/* Updated: 2022/07/20 15:00:50 by jmendez ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
int ft_strncmp(char *s1, char *s2, unsigned int n)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
i = 0;
|
||||
while (i < n)
|
||||
{
|
||||
if (s1[i] != s2[i] || s1[i] == '\0' || s2[i] == '\0')
|
||||
{
|
||||
return (s1[i] - s2[i]);
|
||||
}
|
||||
i++;
|
||||
}
|
||||
return (0);
|
||||
}
|
Reference in New Issue
Block a user