-
Notifications
You must be signed in to change notification settings - Fork 0
/
fdf_utils.c
82 lines (73 loc) · 1.72 KB
/
fdf_utils.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
70
71
72
73
74
75
76
77
78
79
80
81
82
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* fdf_utils.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jmykkane <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/01/02 11:11:55 by jmykkane #+# #+# */
/* Updated: 2023/01/02 11:11:57 by jmykkane ### ########.fr */
/* */
/* ************************************************************************** */
#include "fdf.h"
void find_top(t_fdf_data_set *s)
{
int i;
int l;
int max;
int temp;
char **row;
i = -1;
l = -1;
max = 0;
while (s->d.arr[++i] != NULL)
{
row = ft_split(s->d.arr[i], ' ');
while (row[++l] != NULL)
{
if (row[l] != NULL)
{
temp = ft_atoi(row[l]);
if (temp > max)
max = temp;
}
}
ft_free(row);
l = -1;
}
s->d.z_max = max;
}
int count_rows(char **arr)
{
int count;
count = 0;
while (arr[count] != NULL)
count++;
return (count - 1);
}
int count_columns(char **arr)
{
int count;
count = -1;
while (arr[++count] != NULL)
;
return (count);
}
int line_count(char **argv)
{
int fd;
int count;
char *line;
count = 1;
fd = open(argv[1], O_RDONLY);
line = get_next_line(fd);
while (line)
{
free(line);
line = get_next_line(fd);
count++;
}
free(line);
close(fd);
return (count);
}