From 56c807a9cdd27f683dbced4788fc255ee9450305 Mon Sep 17 00:00:00 2001 From: Supermjork Date: Mon, 21 Aug 2023 12:53:38 +0300 Subject: [PATCH] char insertion poopoo --- printf.c | 6 ++++++ tests/char_print.c | 15 +++++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 tests/char_print.c diff --git a/printf.c b/printf.c index c96a1e9..c202b0d 100644 --- a/printf.c +++ b/printf.c @@ -15,6 +15,7 @@ int _printf(const char *format, ...) unsigned int identifiers = _contains(format, '%'); unsigned int BUFF_SIZE = _strlen(format) - (identifiers * 2); char *buffer, *next; + char c; va_list args; va_start(args, format); @@ -36,6 +37,11 @@ int _printf(const char *format, ...) fmt_idx += 2; break; case 'c': /* add 1 byte and i++ */ + c = va_arg(args, int); + *(buffer + buff_idx + 1) = c; + BUFF_SIZE = _strlen(buffer); + buff_idx += 1; + fmt_idx += 2; break; case '%': /*add 1 byte*/ break; diff --git a/tests/char_print.c b/tests/char_print.c new file mode 100644 index 0000000..8a55f24 --- /dev/null +++ b/tests/char_print.c @@ -0,0 +1,15 @@ +#include "../main.h" + +/** + * main - testing printing of only char + * + * Return: deadth + */ + +int main(void) +{ + char c = 97; + + _printf("cat: %c", c); + return (1); +}