aboutsummaryrefslogtreecommitdiff
path: root/c07/ex02/ft_ultimate_range.c
diff options
context:
space:
mode:
Diffstat (limited to 'c07/ex02/ft_ultimate_range.c')
-rw-r--r--c07/ex02/ft_ultimate_range.c34
1 files changed, 34 insertions, 0 deletions
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 <charles.cabergs@gmail.com> +#+ +:+ +#+ */
+/* +#+#+#+#+#+ +#+ */
+/* Created: 2019/07/07 16:09:06 by cacharle #+# #+# */
+/* Updated: 2019/07/08 08:38:29 by cacharle ### ########.fr */
+/* */
+/* ************************************************************************** */
+
+#include <stdlib.h>
+
+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);
+}