-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcount.c
51 lines (46 loc) · 1.36 KB
/
count.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* count.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: kristori <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/11/09 12:31:34 by kristori #+# #+# */
/* Updated: 2022/11/15 13:25:32 by kristori ### ########.fr */
/* */
/* ************************************************************************** */
#include "so_long.h"
void ft_count_lines(t_program *program)
{
char *line;
int fd;
fd = open(program->map_path, O_RDONLY);
line = "";
while (line != NULL)
{
line = get_next_line(fd);
program->n_lines++;
free(line);
}
fd = close(fd);
}
void ft_count_object(t_program *program)
{
int k;
int i;
k = 0;
i = 0;
while (program->map[k] != 0)
{
while (program->map[k][i])
{
if (program->map[k][i] == 'C')
{
program->n_object++;
}
i++;
}
i = 0;
k++;
}
}