diff options
| author | Charles <sircharlesaze@gmail.com> | 2019-08-06 18:19:11 +0200 |
|---|---|---|
| committer | Charles <sircharlesaze@gmail.com> | 2019-08-06 18:19:11 +0200 |
| commit | c6d343fccb84e9fc89dfc75b3f35a352e97b14a4 (patch) | |
| tree | 5cde66a3b489c7882b6d7ba062df5a70dbaf0666 /c02/ex12 | |
| parent | 056a88ee9c2c9e26f9712d14c645e367d851f394 (diff) | |
| download | piscine-c6d343fccb84e9fc89dfc75b3f35a352e97b14a4.tar.gz piscine-c6d343fccb84e9fc89dfc75b3f35a352e97b14a4.tar.bz2 piscine-c6d343fccb84e9fc89dfc75b3f35a352e97b14a4.zip | |
details, print_memory start
- copied c09 correct ft_split to c07
- strdup parenthesis in malloc
- strlcat copied from tested libft
Diffstat (limited to 'c02/ex12')
| -rw-r--r-- | c02/ex12/ft_print_memory.c | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/c02/ex12/ft_print_memory.c b/c02/ex12/ft_print_memory.c new file mode 100644 index 0000000..442d6e4 --- /dev/null +++ b/c02/ex12/ft_print_memory.c @@ -0,0 +1,44 @@ +#include <unistd.h> + +void xy_putchar(char c) +{ + write(1, &c, 1); +} + +void *ft_print_memory(void *addr, unsigned int size) +{ + int i; + unsigned char *cursor; + char *hex_symbols; + + cursor = (unsigned char*)addr; + hex_symbols = "0123456789abcdef"; + i = 0; + /* while (i < size) */ + /* { */ + /* i = 0; */ + while (i < size) + { + xy_putchar(hex_symbols[cursor[i] / 16]); + xy_putchar(hex_symbols[cursor[i] % 16]); + if ((i + 1) % 2 == 0) + xy_putchar(' '); + i++; + /* } */ + /* i = 0; */ + /* while(i % 16 != 0 && i < size) */ + /* { */ + /* i++; */ + /* } */ + /* i = 0; */ + /* while(i % 16 != 0 && i < size) */ + /* { */ + /* cursor++; */ + /* i++; */ + /* } */ + /* i++; */ + } + return (addr); +} + +//if (cursor[i] >= ' ' && cursor[i] <= '~') |
