From bc32277deb906dbadb8477b818acb1e8773cd911 Mon Sep 17 00:00:00 2001 From: LinlyBoi Date: Mon, 21 Aug 2023 13:41:10 +0300 Subject: [PATCH] yes --- printf.c | 4 ++-- tests/char_print.c | 2 +- tests/strcpy.c | 6 +++++- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/printf.c b/printf.c index ef88cc6..629b578 100644 --- a/printf.c +++ b/printf.c @@ -19,7 +19,7 @@ int _printf(const char *format, ...) va_start(args, format); identifiers = _contains(format, '%'); - BUFF_SIZE = _strlen(format) - identifiers; + BUFF_SIZE = _strlen(format) - (identifiers * 2); buffer = malloc(BUFF_SIZE); if (!format) /* No string. No laundry */ @@ -38,7 +38,7 @@ int _printf(const char *format, ...) break; case 'c': /* add 1 byte and i++ */ c = (char) va_arg(args, int); - *(buffer + buff_idx) = c; + BUFF_SIZE += 1; buff_idx += 1; break; diff --git a/tests/char_print.c b/tests/char_print.c index ff4af74..9bbe388 100644 --- a/tests/char_print.c +++ b/tests/char_print.c @@ -8,7 +8,7 @@ int main(void) { - char c = 97; + char c = 'c'; _printf("cat: %c", c); return (0); diff --git a/tests/strcpy.c b/tests/strcpy.c index d2edc4b..625d9d9 100644 --- a/tests/strcpy.c +++ b/tests/strcpy.c @@ -1,17 +1,21 @@ #include "../main.h" #include #include +#include /** * main - why does this not work! I know! * Return: 0...unless? */ int main(void) { - char *str, *str2; + char *str, *str2, c; str = "hello"; str2 = " world!\n"; str = _strcpy(str, str2); + c = 'c'; + printf("%s", str); + write(1, &c, 1); return (0); }