-
Notifications
You must be signed in to change notification settings - Fork 1
/
ft_other.c
executable file
·82 lines (73 loc) · 1.75 KB
/
ft_other.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_other.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: dzui <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/08/10 21:11:47 by dzui #+# #+# */
/* Updated: 2017/08/10 21:11:48 by dzui ### ########.fr */
/* */
/* ************************************************************************** */
#include "lem_in.h"
int ft_is_comment(char *str)
{
int i;
i = 0;
while (str[i] == '#')
i++;
if (i == 0)
return (0);
return (1);
}
int ft_count_char(char *str, char ch)
{
int i;
int nb;
i = 0;
nb = 0;
while (str[i])
{
if (str[i] == ch)
nb++;
i++;
}
return (nb);
}
uintmax_t ft_atoi_unsigned(char *str)
{
uintmax_t number;
uintmax_t pow;
int i;
i = 0;
pow = 1;
number = 0;
while (str[i])
{
pow *= 10;
i++;
}
i = 0;
pow /= 10;
while (pow != 0)
{
number += (str[i] - '0') * pow;
pow /= 10;
i++;
}
return (number);
}
void ft_join(t_lem *lem, char *str2)
{
char *res;
char *temp;
int sum;
sum = (int)(2 + ft_strlen(lem->input_data) + ft_strlen(str2));
temp = lem->input_data;
res = (char *)malloc(sum * sizeof(char));
ft_strcpy(res, lem->input_data);
ft_strcat(res, str2);
ft_strcat(res, "\n");
free(temp);
lem->input_data = res;
}