diff --git a/src/printf.c b/src/printf.c index 87d0c16..57b5883 100644 --- a/src/printf.c +++ b/src/printf.c @@ -192,7 +192,10 @@ void kernaux_printf_va( break; } - if (formatter.type == TYPE_s) { + if (formatter.type == TYPE_PERCENT) { + putchar('%'); + } + else if (formatter.type == TYPE_s) { const char *const arg = va_arg(va, char*); for (const char *arg_ptr = arg; *arg_ptr; ++arg_ptr) { diff --git a/tests/test_printf.c b/tests/test_printf.c index 746e12f..5e8b0af 100644 --- a/tests/test_printf.c +++ b/tests/test_printf.c @@ -42,6 +42,7 @@ int main() test("Hello, World!", "Hello, World!"); test("Hello, Alex!", "Hello, %s!", "Alex"); test("Hello, Alex!", "Hello, %c%c%c%c!", 'A', 'l', 'e', 'x'); + test("%", "%%"); return 0; }