-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_emptydots.c
37 lines (34 loc) · 1.22 KB
/
ft_emptydots.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_emptydots.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ciglesia <ciglesia@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/11/20 11:19:04 by ciglesia #+# #+# */
/* Updated: 2020/11/20 12:04:06 by ciglesia ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_emptydots(char *str)
{
char *new;
size_t dots;
int i;
int j;
dots = ft_countchr(str, '.');
if (dots == ft_strlen(str))
return (ft_strdup(str));
new = ft_strnew(ft_strlen(str) - dots);
i = 0;
j = 0;
while (str[i])
{
if (str[i] != '.')
new[j++] = str[i];
i++;
}
new[j] = '\0';
free(str);
return (new);
}