printf prints all digits in numbers

This commit is contained in:
MonkeyGG2 2024-02-18 11:14:23 -05:00
parent b1b6ef6005
commit 59166df80b

View File

@ -60,19 +60,23 @@ printf(const char *format, ...)
if (format[i + 1] == 'd' || format[i + 1] == 'i') { if (format[i + 1] == 'd' || format[i + 1] == 'i') {
//integer numbers //integer numbers
const s32 num = va_arg(list, s32); const s32 num = va_arg(list, s32);
vga_write(itoa(num, strbuf, 10), 1, 0x0f); const char* str = itoa(num, strbuf, 10);
vga_write(str, sizeof(str), 0x0f);
} else if (format[i + 1] == 'o') { } else if (format[i + 1] == 'o') {
//octal numbers //octal numbers
const s32 num = va_arg(list, s32); const s32 num = va_arg(list, s32);
vga_write(itoa(num, strbuf, 8), 1, 0x0f); const char *str = itoa(num, strbuf, 8);
vga_write(str, sizeof(str), 0x0f);
} else if (format[i + 1] == 'u') { } else if (format[i + 1] == 'u') {
//unsigned integers //unsigned integers
const u32 num = va_arg(list, u32); const u32 num = va_arg(list, u32);
vga_write(utoa(num, strbuf, 10), 1, 0x0f); const char *str = utoa(num, strbuf, 10);
vga_write(str, sizeof(str), 0x0f);
} else if (format[i + 1] == 'x') { } else if (format[i + 1] == 'x') {
//hexadecimal numbers //hexadecimal numbers
const u32 num = va_arg(list, u32); const u32 num = va_arg(list, u32);
vga_write(utoa(num, strbuf, 16), 1, 0x0f); const char* str = utoa(num, strbuf, 16);
vga_write(str, sizeof(str), 0x0f);
} else if (format[i + 1] == 's') { } else if (format[i + 1] == 's') {
//strings //strings
const char *str = va_arg(list, char*); const char *str = va_arg(list, char*);