ft_strcmp

This commit is contained in:
Tanguy MAZE
2018-04-05 12:58:33 +02:00
parent e50dcca5e8
commit 2446ae93b8
2 changed files with 30 additions and 1 deletions

View File

@@ -6,7 +6,7 @@
# By: tmaze <marvin@42.fr> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2018/04/04 10:51:59 by tmaze #+# #+# #
# Updated: 2018/04/05 11:40:07 by tmaze ### ########.fr #
# Updated: 2018/04/05 12:34:54 by tmaze ### ########.fr #
# #
#******************************************************************************#
@@ -27,6 +27,7 @@ SRCS = \
ft_strrchr.c \
ft_strstr.c \
ft_strnstr.c \
ft_strcmp.c \
ft_isalpha.c \
ft_isdigit.c \
ft_isalnum.c \

28
ft_strcmp.c Normal file
View File

@@ -0,0 +1,28 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strcmp.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: tmaze <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2018/04/03 15:38:27 by tmaze #+# #+# */
/* Updated: 2018/04/05 11:53:33 by tmaze ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
int ft_strcmp(const char *s1, const char *s2)
{
int i;
int diff;
i = 1;
diff = s1[0] - s2[0];
while (diff == 0 && s1[i - 1] && s2[i - 1])
{
diff = s1[i] - s2[i];
i++;
}
return (diff);
}