You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
1.4 KiB
39 lines
1.4 KiB
3 years ago
|
/* ************************************************************************** */
|
||
|
/* */
|
||
|
/* ::: :::::::: */
|
||
2 years ago
|
/* ft_print_ptr.c :+: :+: :+: */
|
||
3 years ago
|
/* +:+ +:+ +:+ */
|
||
|
/* By: narnaud <narnaud@student.42.fr> +#+ +:+ +#+ */
|
||
|
/* +#+#+#+#+#+ +#+ */
|
||
|
/* Created: 2021/10/27 10:13:07 by narnaud #+# #+# */
|
||
|
/* Updated: 2021/12/21 09:50:41 by narnaud ### ########.fr */
|
||
|
/* */
|
||
|
/* ************************************************************************** */
|
||
|
|
||
|
#include "ft_printf.h"
|
||
|
|
||
2 years ago
|
void ft_print_ptr(void *ptr, t_opts *opts)
|
||
3 years ago
|
{
|
||
2 years ago
|
char *raw;
|
||
2 years ago
|
char *nbr;
|
||
3 years ago
|
|
||
2 years ago
|
if (ptr == NULL)
|
||
|
raw = ft_strdup("(nil)");
|
||
|
else
|
||
|
{
|
||
|
raw = ft_itox((unsigned long long int)ptr, "0123456789abcdef");
|
||
|
raw = ft_append(ft_strdup("0x"), raw);
|
||
|
}
|
||
|
nbr = ptr_opts_transform(raw, opts);
|
||
|
opts->dot = 0;
|
||
2 years ago
|
ft_print_str(nbr, opts);
|
||
2 years ago
|
free(raw);
|
||
|
free(nbr);
|
||
3 years ago
|
}
|
||
|
|
||
2 years ago
|
void va_print_ptr(va_list va_ptr, const char *str, t_opts *opts)
|
||
3 years ago
|
{
|
||
|
(void)*str;
|
||
2 years ago
|
ft_print_ptr(va_arg(va_ptr, void *), opts);
|
||
3 years ago
|
}
|