/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_range.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: whaffman +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/06/16 15:57:44 by whaffman #+# #+# */ /* Updated: 2024/06/17 10:13:54 by whaffman ### ########.fr */ /* */ /* ************************************************************************** */ #include #include int *ft_range(int min, int max) { int *res; int *ores; if (min >= max) return ((void *) 0); res = (int *) malloc((max - min) * sizeof(int)); ores = res; while (min < max) { *res = min; res++; min++; } return (ores); } #ifdef DEBUG void test(int min, int max) { int *range; range = ft_range(min, max); if (!range) { printf("NULL POINTER\n"); return ; } while (min < max) { printf("%d ", *range++); min++; } printf("\n"); } int main(void) { test(-3, 3); test(0, 10); test(-10, 2); test(3, -3); test(3, 3); return (0); } #endif