too many variables no more

This commit is contained in:
LinlyBoi
2023-08-22 18:55:55 +03:00
parent 9bd0766dac
commit edf0375cf4

View File

@@ -9,22 +9,16 @@
**/ **/
int _printf(const char *format, ...) int _printf(const char *format, ...)
{ {
int buff_idx, fmt_idx; /* Indexes */ unsigned int buff_idx, fmt_idx, printed;
unsigned int identifiers, BUFF_SIZE, printed;
char *buffer; /*where non formated things are stored*/ char *buffer; /*where non formated things are stored*/
va_list args; 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 */ if (!format && !buffer) /* No string. No laundry */
return (0); return (0);
va_start(args, format);
buff_idx = fmt_idx = 0; /*chain assignment*/ buffer = (char *) malloc(_strlen(format) - _contains(format,'%')); /* sized of the non % instances only*/
printed = 0; /*this alone due to diff type*/ buff_idx = fmt_idx = printed = 0; /*chain assignment*/
while (*(format + fmt_idx)) while (*(format + fmt_idx))
{ {
if ((*(format + fmt_idx) == '%') && (*(format + fmt_idx + 1))) if ((*(format + fmt_idx) == '%') && (*(format + fmt_idx + 1)))