-
Notifications
You must be signed in to change notification settings - Fork 0
/
figure.c
executable file
·69 lines (62 loc) · 1.73 KB
/
figure.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* figure.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ioleksiu <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/05/05 13:10:44 by ioleksiu #+# #+# */
/* Updated: 2017/05/07 18:28:23 by ioleksiu ### ########.fr */
/* */
/* ************************************************************************** */
#include "filler.h"
void figure_size(t_filler *f)
{
char *line;
int i;
i = 6;
get_next_line(0, &line);
f->size_figure_x = ft_atoi(&line[i]);
while (line[i] != ' ')
i++;
f->size_figure_y = ft_atoi(&line[++i]);
free(line);
}
void memory_allocate_figure(t_filler *f)
{
int i;
i = 0;
f->figure = (char**)malloc(sizeof(char*) * f->size_figure_x);
while (i < f->size_figure_x)
{
f->figure[i] = (char *)malloc(sizeof(char) * f->size_figure_y + 1);
ft_bzero(f->figure[i], (size_t)(f->size_figure_y + 1));
i++;
}
}
void fill_figure(t_filler *f)
{
int i;
int x;
int y;
char *line;
i = 0;
x = 0;
y = 0;
get_next_line(0, &line);
while (x < f->size_figure_x)
{
while (y < f->size_figure_y)
{
f->figure[x][y] = line[i];
i++;
y++;
}
x++;
y = 0;
i = 0;
free(line);
if (x < f->size_figure_x)
get_next_line(0, &line);
}
}