char -> unsigned char

This commit is contained in:
Timo Schmidt 2023-03-22 20:23:53 +01:00
parent bf3e0dcb5c
commit 20694b2ce9
2 changed files with 12 additions and 18 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 19:18:28 by tischmid ### ########.fr */
/* Updated: 2023/03/22 20:22:36 by tischmid ### ########.fr */
/* */
/* ************************************************************************** */
@ -24,20 +24,14 @@ void print_hex(ULL addr_number, int length)
digits = "0123456789abcdef";
if (addr_number < 16)
{
// while (--length > 0)
// write(1, "0", 1);
printf("[ull: %llu, pad: %d]=", addr_number, length);
fflush(stdout);
while (--length > 0)
write(1, "0", 1);
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)
@ -55,8 +49,8 @@ void print_addr_vals(void *addr, unsigned int width, int hex, char *delim)
while (width-- > 0)
{
if (hex)
print_hex(*(char *)addr, 2);
else if (*(char *)addr > 31 && *(char *)addr < 127)
print_hex(*(unsigned char *) addr, 2);
else if (*(unsigned char *) addr > 31 && *(unsigned char *) addr < 127)
write(1, addr, 1);
else
write(1, ".", 1);
@ -110,13 +104,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";
ptr = "hello";
ptr = "hello world";
ptr = "hello whatever";
ptr = "hello loook";
ptr = "hello";
ptr = "hello";
ft_print_memory(ptr, 1000);
// ptr = "hello";
// ptr = "hello world";
// ptr = "hello whatever";
// ptr = "hello loook";
// ptr = "hello";
// ptr = "hello";
ft_print_memory(ptr, 92);
return (0);
}
*/ ////

BIN
ex12/main Executable file

Binary file not shown.