1
0
This repository has been archived on 2024-10-25. You can view files and clone it, but cannot push or open issues or pull requests.
42-2nd-piscine/C07/ex02/ft_ultimate_range.c

40 lines
1.2 KiB
C
Raw Normal View History

2023-08-03 23:16:27 +02:00
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_ultimate_range.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: adjoly <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/07/27 19:51:50 by adjoly #+# #+# */
/* Updated: 2023/08/03 20:25:00 by adjoly ### ########.fr */
/* */
/* ************************************************************************** */
#include <stdlib.h>
int ft_ultimate_range(int **range, int min, int max)
{
int i;
int *arr;
i = 0;
if (min >= max)
{
*range = 0;
return (0);
}
arr = malloc((max - min) * sizeof(int));
if (arr == NULL)
{
*range = 0;
return (-1);
}
while (min < max)
{
arr[i] = min + i;
i++;
}
*range = arr;
return (max - min);
}