aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCharles <sircharlesaze@gmail.com>2020-02-04 03:39:35 +0100
committerCharles <sircharlesaze@gmail.com>2020-02-04 03:39:35 +0100
commit435fec311c0c5173ae99c32b8f4e6431bd1e43d2 (patch)
treecdcfe1672c8343c41c59087a9ff23500f32cfca8
parentf4e1232957b1270da70f57fcad4cd6371947e442 (diff)
downloadlibft-435fec311c0c5173ae99c32b8f4e6431bd1e43d2.tar.gz
libft-435fec311c0c5173ae99c32b8f4e6431bd1e43d2.tar.bz2
libft-435fec311c0c5173ae99c32b8f4e6431bd1e43d2.zip
Added ft_abs
-rw-r--r--Makefile5
-rw-r--r--ft_abs.c18
-rw-r--r--libft.h18
3 files changed, 31 insertions, 10 deletions
diff --git a/Makefile b/Makefile
index eeba965..72c315a 100644
--- a/Makefile
+++ b/Makefile
@@ -6,7 +6,7 @@
# By: cacharle <marvin@42.fr> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2019/10/08 15:45:53 by cacharle #+# #+# #
-# Updated: 2020/02/02 22:09:07 by cacharle ### ########.fr #
+# Updated: 2020/02/04 03:32:29 by cacharle ### ########.fr #
# #
# **************************************************************************** #
@@ -27,7 +27,8 @@ SRC = ft_atoi.c ft_bzero.c ft_isalnum.c ft_isalpha.c ft_isascii.c ft_isdigit.c f
ft_striteri.c ft_strjoin.c ft_strlcat.c ft_strlen.c ft_strmap.c ft_strmapi.c \
ft_strncat.c ft_strncmp.c ft_strncpy.c ft_strnequ.c ft_strnew.c ft_strnstr.c \
ft_strrchr.c ft_split.c ft_strstr.c ft_substr.c ft_strtrim.c ft_tolower.c \
- ft_toupper.c ft_strlcpy.c ft_calloc.c ft_strcount.c ft_memswap.c ft_qsort.c
+ ft_toupper.c ft_strlcpy.c ft_calloc.c ft_strcount.c ft_memswap.c ft_qsort.c \
+ ft_abs.c
OBJ = $(SRC:.c=.o)
INCLUDE = libft.h
diff --git a/ft_abs.c b/ft_abs.c
new file mode 100644
index 0000000..14492cd
--- /dev/null
+++ b/ft_abs.c
@@ -0,0 +1,18 @@
+/* ************************************************************************** */
+/* */
+/* ::: :::::::: */
+/* ft_abs.c :+: :+: :+: */
+/* +:+ +:+ +:+ */
+/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */
+/* +#+#+#+#+#+ +#+ */
+/* Created: 2020/02/04 03:31:16 by cacharle #+# #+# */
+/* Updated: 2020/02/04 03:32:54 by cacharle ### ########.fr */
+/* */
+/* ************************************************************************** */
+
+#include "libft.h"
+
+int ft_abs(int i)
+{
+ return (i < 0 ? -i : i);
+}
diff --git a/libft.h b/libft.h
index f84c16e..4f8f04e 100644
--- a/libft.h
+++ b/libft.h
@@ -6,7 +6,7 @@
/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/10/07 09:45:02 by cacharle #+# #+# */
-/* Updated: 2020/02/02 22:09:47 by cacharle ### ########.fr */
+/* Updated: 2020/02/04 03:33:44 by cacharle ### ########.fr */
/* */
/* ************************************************************************** */
@@ -107,16 +107,18 @@ t_list *ft_lstmap(t_list *lst, void *(*f)(void *),
typedef struct
{
- int lo;
- int hi;
-} t_ftrange;
+ int lo;
+ int hi;
+} t_ftrange;
-typedef int (*t_ftcompar_func)(const void*, const void*);
+typedef int (*t_ftcompar_func)(const void*, const void*);
-t_bool ft_is_set(void *base, size_t nel, size_t width,
+t_bool ft_is_set(void *base, size_t nel, size_t width,
t_ftcompar_func compar);
-void ft_qsort(void *base, size_t nel, size_t width,
+void ft_qsort(void *base, size_t nel, size_t width,
t_ftcompar_func compar);
-int ft_compar_int(const void *a, const void *b);
+int ft_compar_int(const void *a, const void *b);
+
+int ft_abs(int i);
#endif