first commit
This commit is contained in:
36
ended/C07/ex01/ft_range.c
Normal file
36
ended/C07/ex01/ft_range.c
Normal file
@ -0,0 +1,36 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_range.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: ajoly <ajoly@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/08/01 15:14:57 by ajoly #+# #+# */
|
||||
/* Updated: 2022/08/04 12:52:11 by ajoly ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
int *ft_range(int min, int max)
|
||||
{
|
||||
int i;
|
||||
int *result;
|
||||
int diff;
|
||||
|
||||
diff = max - min;
|
||||
result = malloc((diff + 1) * sizeof(int));
|
||||
i = 0;
|
||||
if (min >= max)
|
||||
{
|
||||
result = NULL;
|
||||
return (result);
|
||||
}
|
||||
while (min < max)
|
||||
{
|
||||
result[i] = min;
|
||||
i++;
|
||||
min++;
|
||||
}
|
||||
return (result);
|
||||
}
|
Reference in New Issue
Block a user