-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_range.c
More file actions
38 lines (35 loc) · 1.21 KB
/
ft_range.c
File metadata and controls
38 lines (35 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_range.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: bwebb <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/01/23 18:12:00 by bwebb #+# #+# */
/* Updated: 2019/05/30 11:58:52 by bwebb ### ########.fr */
/* */
/* ************************************************************************** */
#include <stdlib.h>
int *ft_range(int min, int max)
{
int *str;
int i;
int j;
if (min >= max)
return (NULL);
if (min < 0 && max < 0)
i = abs(min) + max;
else if (min < 0 && max >= 0)
i = max + abs(min) + 1;
else
i = max - min;
str = (int*)malloc(i);
j = 0;
while (min != max)
{
str[j] = min;
j++;
min++;
}
return (str);
}