12345678910111213141516171819202122232425262728293031323334 |
- /* Create a function ft_range which returns an array ofints. This int array should
- contain all values between min and max.
- Min included - max excluded. */
- #include <stdio.h>
- #include <stdlib.h>
- int *ft_range(int min, int max)
- {
- int len, i;
- int * array;
- if (min >= max)
- return (0);
- len = max - min;
-
- i = 0;
- array = (int*)malloc(sizeof(int) * (len));
- if (array == NULL)
- return (NULL);
- while (len--)
- {
- array[i] = min + i;
- i++;
- }
- return (array);
- }
-
- int main(void)
- {
- printf("%d", ft_range(2, 5));
- return (0);
- }
|