I have a segment fault int this exercice.
Instruction:
• Write an ft_ultimate_range function which allocates and assigns an int array. This int table will contain all values between min and max.
• Min included - max excluded.
• If the min value is greater than or equal to the max value, range will point to NULL.
• The range size will be returned (or 0 in the event of a problem).
#include <stdlib.h>
#include <stdio.h>
int ft_ultimate_range(int **range, int min ,int max)
{
int len;
int i;
i = 0;
len = max - min;
if (min >= max)
{
*range = NULL;
return(0);
}
**range = (int)malloc(sizeof(int) * len);
while (min < max)
{
range[0][i] = min;
i++;
min++;
}
return(len);
}
int main()
{
int min;
int max;
int **range = NULL;
min = 0;
max = 10;
printf("%d\n", ft_ultimate_range(range, min, max));
return(0);
}