resolue probleme signe moins avec flag zero mais erreur norme

This commit is contained in:
Hugo LAMY
2020-03-09 15:06:54 +01:00
parent 12d30893f8
commit c55004d845
4 changed files with 35 additions and 5 deletions

View File

@@ -94,6 +94,7 @@ char *ft_precision(char *s, char *print, char *type)
char *width_flags(char *print, char *s, int width, int zero)
{
char *tmp;
char *minus;
char c;
int len;
@@ -107,9 +108,16 @@ char *width_flags(char *print, char *s, int width, int zero)
}
else
{
c = (ft_strchr(s, '0')) ? '0' : ' ';
ft_memset(tmp, c, width - len);
// c = (ft_strchr(s, '0')) ? '0' : ' ';
// ft_memset(tmp, c, width - len);
ft_memset(tmp, (ft_strchr(s, '0')) ? '0' : ' ', width - len);
ft_memmove(ft_strchr(tmp, '\0') + zero, print, ft_strlen(print));
// if (c == '0' && (minus = ft_strchr(tmp, '-')))
if (ft_strchr(s, '0') && (minus = ft_strchr(tmp, '-')))
{
minus[0] = '0';
tmp[0] = '-';
}
}
free(print);
return (tmp);