-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_read_trm.c
executable file
·41 lines (38 loc) · 1.27 KB
/
ft_read_trm.c
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
39
40
41
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_read_trm.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: istalevs <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/12/28 23:25:00 by istalevs #+# #+# */
/* Updated: 2017/12/29 12:38:01 by istalevs ### ########.fr */
/* */
/* ************************************************************************** */
#include "fillit.h"
int *ft_read_trm(char const *trm_char)
{
int *trm_int;
int i;
int n;
int y;
size_t count;
i = 0;
n = 0;
y = 0;
count = 0;
if ((trm_int = (int*)malloc(sizeof(int) * 8)) == NULL)
return (NULL);
while (i < 21)
{
if (*(trm_char + i) == '#')
{
trm_int[count++] = i - n;
trm_int[count++] = y;
}
i++;
if (i % 5 == 0 && ++y)
n += 5;
}
return (trm_int);
}