ft_strcmp
This commit is contained in:
3
Makefile
3
Makefile
@@ -6,7 +6,7 @@
|
|||||||
# By: tmaze <marvin@42.fr> +#+ +:+ +#+ #
|
# By: tmaze <marvin@42.fr> +#+ +:+ +#+ #
|
||||||
# +#+#+#+#+#+ +#+ #
|
# +#+#+#+#+#+ +#+ #
|
||||||
# Created: 2018/04/04 10:51:59 by tmaze #+# #+# #
|
# 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_strrchr.c \
|
||||||
ft_strstr.c \
|
ft_strstr.c \
|
||||||
ft_strnstr.c \
|
ft_strnstr.c \
|
||||||
|
ft_strcmp.c \
|
||||||
ft_isalpha.c \
|
ft_isalpha.c \
|
||||||
ft_isdigit.c \
|
ft_isdigit.c \
|
||||||
ft_isalnum.c \
|
ft_isalnum.c \
|
||||||
|
28
ft_strcmp.c
Normal file
28
ft_strcmp.c
Normal 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);
|
||||||
|
}
|
Reference in New Issue
Block a user