42_C_PISCINE/C/c07v2/ex01/ft_range.c

32 lines
1.1 KiB
C
Raw Normal View History

2023-05-17 12:45:25 -04:00
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_range.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/07/21 18:54:20 by cchauvet #+# #+# */
/* Updated: 2022/08/01 14:36:12 by cchauvet ### ########.fr */
/* */
/* ************************************************************************** */
#include <stdlib.h>
int *ft_range(int min, int max)
{
int i;
int *tab;
tab = NULL;
if (max <= min)
return (tab);
tab = malloc(sizeof(*tab) * (max - min));
i = 0;
while (min + i < max)
{
*(tab + i) = min + i;
i++;
}
return (tab);
}