Archived
first commit
This commit is contained in:
1 parent
7f3254f1c5
commit
a80c4d61d7
133 files changed
+4293
No files matched your search
@@ -0,0 +1,39 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* 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);
|
||||
}
|
||||
Reference in new issue
Block a user