From edf0375cf4480e3a50e22c51eb28bea71bdef9fb Mon Sep 17 00:00:00 2001 From: LinlyBoi Date: Tue, 22 Aug 2023 18:55:55 +0300 Subject: [PATCH] too many variables no more --- printf.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/printf.c b/printf.c index 13deb7e..f1106cd 100644 --- a/printf.c +++ b/printf.c @@ -9,22 +9,16 @@ **/ int _printf(const char *format, ...) { - int buff_idx, fmt_idx; /* Indexes */ - unsigned int identifiers, BUFF_SIZE, printed; + unsigned int buff_idx, fmt_idx, printed; char *buffer; /*where non formated things are stored*/ va_list args; - va_start(args, format); - - identifiers = _contains(format, '%'); /* instances of %s, %c etc */ - BUFF_SIZE = _strlen(format) - identifiers; - buffer = (char *) malloc(BUFF_SIZE); /* sized of the non % instances only*/ - if (!format && !buffer) /* No string. No laundry */ return (0); + va_start(args, format); - buff_idx = fmt_idx = 0; /*chain assignment*/ - printed = 0; /*this alone due to diff type*/ + buffer = (char *) malloc(_strlen(format) - _contains(format,'%')); /* sized of the non % instances only*/ + buff_idx = fmt_idx = printed = 0; /*chain assignment*/ while (*(format + fmt_idx)) { if ((*(format + fmt_idx) == '%') && (*(format + fmt_idx + 1)))