printf prints all digits in numbers
This commit is contained in:
parent
b1b6ef6005
commit
59166df80b
12
sys/lib.c
12
sys/lib.c
|
@ -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*);
|
||||||
|
|
Loading…
Reference in New Issue