42_C_PISCINE/C/c07v1/ex02/ft_ultimate_range.c

31 lines
1.1 KiB
C
Raw Normal View History

2023-05-17 12:45:25 -04:00
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_ultimate_range.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/07/22 10:33:24 by cchauvet #+# #+# */
/* Updated: 2022/07/26 17:50:02 by cchauvet ### ########.fr */
/* */
/* ************************************************************************** */
#include <stdlib.h>
int ft_ultimate_range(int **range, int min, int max)
{
int i;
*range = NULL;
if (max <= min)
return (0);
*range = malloc(sizeof(*range) * (max - min));
i = 0;
while (min + i < max)
{
(*range)[i] = min + i;
i++;
}
return (max - min);
}