From 143261606e6fab6ee19233eb0fac0f59bd467639 Mon Sep 17 00:00:00 2001 From: Lukas Jiriste Date: Sat, 13 Jan 2024 14:50:39 +0100 Subject: [PATCH] Add ft_strcmp function. Add ft_strcmp as it may be more ergonomic than ft_strncmp. Add *.swp rule to .gitignore so that those won't bother me while vim is opened. --- .gitignore | 1 + ft_str/ft_strcmp.c | 27 +++++++++++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 ft_str/ft_strcmp.c diff --git a/.gitignore b/.gitignore index 33ac3dc..50498d8 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ *.[ao] +*.swp .libtemp diff --git a/ft_str/ft_strcmp.c b/ft_str/ft_strcmp.c new file mode 100644 index 0000000..279108c --- /dev/null +++ b/ft_str/ft_strcmp.c @@ -0,0 +1,27 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_strcmp.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: ljiriste +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2024/01/13 14:11:31 by ljiriste #+# #+# */ +/* Updated: 2024/01/13 14:48:37 by ljiriste ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "ft_str.h" +#include + +int ft_strcmp(const char *s1, const char *s2) +{ + size_t i; + + i = 0; + while (s1[i] == s2[i] && s1[i] && s2[i]) + ++i; + if (n > 0) + return ((unsigned char)s1[i] - (unsigned char)s2[i]); + else + return (0); +} -- 2.30.2