-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathtruncate_zeros.c
More file actions
35 lines (32 loc) · 1.18 KB
/
truncate_zeros.c
File metadata and controls
35 lines (32 loc) · 1.18 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* truncate_zeros.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: lilam <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2018/01/15 09:06:41 by lilam #+# #+# */
/* Updated: 2018/01/31 02:38:59 by hiroshius ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_printf.h"
void truncate_zeros(char **str)
{
int i;
int sign;
char *temp;
i = 0;
if (*str[i] == '-')
{
sign = -1;
i++;
}
while ((*str)[i] && (*str)[i] == '0')
i++;
temp = *str;
if (sign == -1)
*str = ft_strjoin("-", *str + i);
else
*str = ft_strdup(*str + i);
free(temp);
}