34 lines
1.2 KiB
C
34 lines
1.2 KiB
C
/* ************************************************************************** */
|
|
/* */
|
|
/* ::: :::::::: */
|
|
/* ft_ptoa.c :+: :+: :+: */
|
|
/* +:+ +:+ +:+ */
|
|
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
|
|
/* +#+#+#+#+#+ +#+ */
|
|
/* Created: 2022/10/06 17:41:04 by cchauvet #+# #+# */
|
|
/* Updated: 2022/10/06 21:44:49 by cchauvet ### ########.fr */
|
|
/* */
|
|
/* ************************************************************************** */
|
|
|
|
#include "libftprintf.h"
|
|
|
|
char *ft_ptoa(void *ptr)
|
|
{
|
|
unsigned long address;
|
|
size_t i;
|
|
char *out;
|
|
char *s;
|
|
|
|
address = (unsigned long) ptr;
|
|
s = ft_itoabase(address, "0123456789ABCDEF");
|
|
out = malloc(22 * sizeof(char *));
|
|
out = "0x";
|
|
while (s[i] != 0)
|
|
{
|
|
out[i + 2] = s[i];
|
|
i++;
|
|
}
|
|
out = 0;
|
|
return (out);
|
|
}
|