mirror of
https://codeberg.org/la-chouette/minishell.git
synced 2025-12-06 07:28:09 +01:00
libs: added libft
This commit is contained in:
parent
6e1552a35d
commit
ddb2306630
63 changed files with 2989 additions and 4 deletions
34
libft/ft_printf_pointer.c
Normal file
34
libft/ft_printf_pointer.c
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_printf_pointer.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: jguelen <jguelen@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/11/18 10:46:34 by jguelen #+# #+# */
|
||||
/* Updated: 2025/02/04 09:50:47 by jguelen ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "ft_printf.h"
|
||||
|
||||
int ft_printf_ptr(int fd, t_printf_format *format)
|
||||
{
|
||||
unsigned long long ptr_hexa;
|
||||
|
||||
ptr_hexa = (unsigned long long)format->var.p;
|
||||
if ((format->flags & ~PRINTF_MINUSFLAG) == format->flags
|
||||
&& ft_pad_char(fd, format, " ") == -1)
|
||||
return (-1);
|
||||
if (ptr_hexa == 0)
|
||||
{
|
||||
if ((format->flags & ~PRINTF_MINUSFLAG) == format->flags)
|
||||
ft_pad_char(fd, format, " ");
|
||||
return (ft_printf_str(fd, "(nil)", INT_MAX),
|
||||
ft_pad_char(fd, format, " "));
|
||||
}
|
||||
if (ft_printf_str(fd, format->prefix, INT_MAX) == -1
|
||||
|| ft_put_ull_base_fd(ptr_hexa, HEXA_LOW, HEX_LEN, fd) == -1)
|
||||
return (-1);
|
||||
return (ft_pad_char(fd, format, " "));
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue