-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_createaddrstr.c
More file actions
39 lines (36 loc) · 1.35 KB
/
Copy pathft_createaddrstr.c
File metadata and controls
39 lines (36 loc) · 1.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_createaddrstr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: Cerdelen < cerdelen@student.42wolfsburg.de +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/12/04 20:12:39 by Cerdelen #+# #+# */
/* Updated: 2021/12/04 20:12:39 by Cerdelen ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_printf.h"
char *createaddrstr(void *ptr)
{
unsigned long int div;
char temp;
unsigned long int addr;
int count;
char *str;
str = calloc (20, sizeof(char));
addr = (unsigned long int)ptr;
div = 1;
count = 0;
while ((addr / div >= 16) && addr >= 16)
div *= 16;
while (div > 0)
{
temp = (addr / div) + '0';
if (temp > '9')
temp += 39;
str[count++] = temp;
addr %= div;
div /= 16;
}
return (str);
}