Implement %% formatter

This commit is contained in:
Alex Kotov 2020-12-07 05:00:24 +05:00
parent 0eb355f1fa
commit 771d0336ca
Signed by: kotovalexarian
GPG Key ID: 553C0EBBEB5D5F08
2 changed files with 5 additions and 1 deletions

View File

@ -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) {

View File

@ -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;
}