From 03b4d8a03fb1b2cf93aaac0dc9d317ff9c2ba705 Mon Sep 17 00:00:00 2001 From: Charles Date: Mon, 8 Jul 2019 12:12:58 +0200 Subject: c05/c06 normed, c07/c08 begining --- c07/ex02/ft_ultimate_range.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 c07/ex02/ft_ultimate_range.c (limited to 'c07/ex02/ft_ultimate_range.c') diff --git a/c07/ex02/ft_ultimate_range.c b/c07/ex02/ft_ultimate_range.c new file mode 100644 index 0000000..141889c --- /dev/null +++ b/c07/ex02/ft_ultimate_range.c @@ -0,0 +1,34 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_ultimate_range.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: cacharle +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2019/07/07 16:09:06 by cacharle #+# #+# */ +/* Updated: 2019/07/08 08:38:29 by cacharle ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include + +int ft_ultimate_range(int **range, int min, int max) +{ + int i; + + if (min >= max) + { + *range = NULL; + return (0); + } + *range = (int*)malloc(sizeof(int) * (max - min)); + if (*range == NULL) + return (-1); + i = 0; + while (i < max - min) + { + (*range)[i] = min + i; + i++; + } + return (i); +} -- cgit