34 lines
1.2 KiB
C
34 lines
1.2 KiB
C
/* ************************************************************************** */
|
|
/* */
|
|
/* ::: :::::::: */
|
|
/* ft_percent_case.c :+: :+: :+: */
|
|
/* +:+ +:+ +:+ */
|
|
/* By: pbonilla <eirodeis.lepnj@gmail.com> +#+ +:+ +#+ */
|
|
/* +#+#+#+#+#+ +#+ */
|
|
/* Created: 2021/03/12 12:21:58 by pbonilla #+# #+# */
|
|
/* Updated: 2021/03/21 20:10:25 by pbonilla ### ########.fr */
|
|
/* */
|
|
/* ************************************************************************** */
|
|
|
|
#include "../includes/ft_printf.h"
|
|
|
|
char *ft_percent_case(t_param *param)
|
|
{
|
|
int len;
|
|
int pos;
|
|
char *s;
|
|
|
|
len = 1;
|
|
pos = 0;
|
|
if (param->width > len)
|
|
len = param->width;
|
|
if (!param->minus)
|
|
pos = len - 1;
|
|
if (!(s = malloc(sizeof(char) * (len + 1))))
|
|
return (NULL);
|
|
s[len] = 0;
|
|
ft_printf_memset(s, len, param);
|
|
s[pos] = '%';
|
|
return (s);
|
|
}
|