added c conversion suport
This commit is contained in:
32
srcs/pf_convc.c
Normal file
32
srcs/pf_convc.c
Normal file
@@ -0,0 +1,32 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* pf_convc.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: tmaze <tmaze@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2019/02/11 09:07:45 by tmaze #+# #+# */
|
||||
/* Updated: 2019/02/11 11:36:49 by tmaze ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "libftprintf.h"
|
||||
|
||||
int pf_convc(t_flags *flags, va_list *ap)
|
||||
{
|
||||
char c;
|
||||
size_t i;
|
||||
|
||||
c = (flags->convtype == 0) ? '%' : (char)va_arg(*ap, int);
|
||||
i = 0;
|
||||
flags->width = (flags->width == 0) ? 1 : flags->width;
|
||||
if ((flags->buffer = pf_strnew(flags->width)) == NULL)
|
||||
return (1);
|
||||
if (flags->minus)
|
||||
flags->buffer[i++] = c;
|
||||
pf_memset(&(flags->buffer[i]), ' ', flags->width - 1);
|
||||
i += flags->width - 1;
|
||||
if (!flags->minus)
|
||||
flags->buffer[i] = c;
|
||||
return (0);
|
||||
}
|
||||
Reference in New Issue
Block a user