Bonus first try
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
/* By: gbaconni@student.42lausanne.ch +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/01/20 11:56:37 by gbaconni #+# #+# */
|
||||
/* Updated: 2022/04/25 07:12:44 by gbaconni ### lausanne.ch */
|
||||
/* Updated: 2022/04/26 17:43:42 by gbaconni ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@@ -14,8 +14,8 @@
|
||||
|
||||
int ft_vprintf_string(const char *format, va_list ap)
|
||||
{
|
||||
int ret;
|
||||
char *s;
|
||||
int ret;
|
||||
char *s;
|
||||
|
||||
(void) format;
|
||||
ret = 0;
|
||||
@@ -25,6 +25,28 @@ int ft_vprintf_string(const char *format, va_list ap)
|
||||
ret = ft_puts("(null)");
|
||||
return (ret);
|
||||
}
|
||||
ret = ft_puts(s);
|
||||
|
||||
const char *f;
|
||||
int flags;
|
||||
int precision;
|
||||
int len;
|
||||
precision = 0;
|
||||
flags = 0;
|
||||
f = format;
|
||||
while (*f != '\0')
|
||||
{
|
||||
if (*f >= '0' && *f <= '9')
|
||||
precision = precision * 10 + *f - '0';
|
||||
if (*f == 'c' || *f == 's' || *f == 'p' || *f == 'd' || *f == 'i' || *f == 'u' || *f == 'x' || *f == 'X' || *f == '%')
|
||||
break ;
|
||||
f++;
|
||||
}
|
||||
if (precision > 0)
|
||||
{
|
||||
len = precision - ft_strlen(s);
|
||||
while (len --> 0)
|
||||
ret += ft_putchar(' ');
|
||||
}
|
||||
ret += ft_puts(s);
|
||||
return (ret);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user