diff --git a/src/printf.c b/src/printf.c index 57b5883..e96fae3 100644 --- a/src/printf.c +++ b/src/printf.c @@ -195,6 +195,16 @@ void kernaux_printf_va( if (formatter.type == TYPE_PERCENT) { putchar('%'); } + else if (formatter.type == TYPE_u) { + const unsigned int arg = va_arg(va, unsigned int); + + char buf[20]; + kernaux_itoa(arg, buf, 'd'); + + for (const char *arg_ptr = buf; *arg_ptr; ++arg_ptr) { + putchar(*arg_ptr); + } + } else if (formatter.type == TYPE_s) { const char *const arg = va_arg(va, char*); diff --git a/tests/test_printf.c b/tests/test_printf.c index 5e8b0af..603dbde 100644 --- a/tests/test_printf.c +++ b/tests/test_printf.c @@ -43,6 +43,7 @@ int main() test("Hello, Alex!", "Hello, %s!", "Alex"); test("Hello, Alex!", "Hello, %c%c%c%c!", 'A', 'l', 'e', 'x'); test("%", "%%"); + test("123", "%u", 123); return 0; }