-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils2.c
More file actions
62 lines (54 loc) · 1.4 KB
/
utils2.c
File metadata and controls
62 lines (54 loc) · 1.4 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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* utils2.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: yaqliu <yaqliu@student.42barcelona.co +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2026/02/02 15:32:19 by yaqliu #+# #+# */
/* Updated: 2026/02/12 00:42:51 by yaqliu ### ########.fr */
/* */
/* ************************************************************************** */
#include "header.h"
int ft_sqrt(int n)
{
int i;
if (n <= 0)
return (0);
i = 1;
while (i <= 46000 && (i * i) <= n)
i++;
return (i - 1);
}
int get_index(int *vector, int value, int size)
{
int i;
i = 0;
while (i < size)
{
if (vector[i] == value)
return (i);
i++;
}
return (-1);
}
void free_split(char **str)
{
int i;
i = 0;
while (str[i])
{
free(str[i]);
i++;
}
free(str);
}
void ft_error(t_stack **a, t_stack **b)
{
if (a)
ft_clear(a);
if (b)
ft_clear(b);
write(2, "Error\n", 6);
exit(1);
}