add libft, add gitignore
This commit is contained in:
34
libft/ft_strcmp.c
Executable file
34
libft/ft_strcmp.c
Executable file
@ -0,0 +1,34 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* 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]);
|
||||
}
|
Reference in New Issue
Block a user