This commit is contained in:
Timo Schmidt 2023-03-22 19:19:45 +01:00
parent 16f11f06a7
commit bf3e0dcb5c
1 changed files with 17 additions and 8 deletions

View File

@ -6,7 +6,7 @@
/* By: tischmid <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/03/21 05:44:01 by tischmid #+# #+# */
/* Updated: 2023/03/22 18:37:44 by tischmid ### ########.fr */
/* Updated: 2023/03/22 19:18:28 by tischmid ### ########.fr */
/* */
/* ************************************************************************** */
@ -21,19 +21,23 @@ void print_hex(ULL addr_number, int length)
int digit;
char *digits;
printf("<%llu %d>", addr_number, length);
fflush(stdout);
digits = "0123456789abcdef";
if (addr_number < 16)
{
while (--length > 0)
write(1, "0", 1);
// while (--length > 0)
// write(1, "0", 1);
printf("[ull: %llu, pad: %d]=", addr_number, length);
fflush(stdout);
write(1, &digits[addr_number], 1);
write(1, "\n", 1);
return ;
}
digit = digits[addr_number % 16];
print_hex(addr_number /= 16, length - 1);
printf("[ull: %llu, pad: %d]=", addr_number, length);
fflush(stdout);
write(1, &digit, 1);
write(1, "\n", 1);
}
int ft_strlen(char *str)
@ -51,7 +55,7 @@ void print_addr_vals(void *addr, unsigned int width, int hex, char *delim)
while (width-- > 0)
{
if (hex)
print_hex(*(unsigned char *)addr, 2);
print_hex(*(char *)addr, 2);
else if (*(char *)addr > 31 && *(char *)addr < 127)
write(1, addr, 1);
else
@ -106,8 +110,13 @@ int main(void)
"\x74\x5f\x6d\x65\x6d\x6f\x72\x79\x0a\x0a"
"\x0a\x09\x6c\x6f\x6c\x2e\x6c\x6f\x6c\x0a"
"\x20\x00";
// char *ptr = "hello";
ft_print_memory(ptr, 146);
ptr = "hello";
ptr = "hello world";
ptr = "hello whatever";
ptr = "hello loook";
ptr = "hello";
ptr = "hello";
ft_print_memory(ptr, 1000);
return (0);
}
*/ ////