more compact code makes my brain happy

This commit is contained in:
LinlyBoi
2023-08-22 14:29:46 +03:00
parent 297cf9c4a5
commit 9e30a97107

View File

@@ -12,7 +12,7 @@ int _printf(const char *format, ...)
{ {
int buff_idx, fmt_idx; int buff_idx, fmt_idx;
unsigned int identifiers, BUFF_SIZE, printed; unsigned int identifiers, BUFF_SIZE, printed;
char *buffer, *next, c; char *buffer;
va_list args; va_list args;
va_start(args, format); va_start(args, format);
@@ -42,12 +42,10 @@ int _printf(const char *format, ...)
switch (*(format + fmt_idx + 1)) /*this needs to shrink*/ switch (*(format + fmt_idx + 1)) /*this needs to shrink*/
{ {
case 's': case 's':
next = va_arg(args, char*); /*Store string temporarily*/ _puts(va_arg(args, char*));
_puts(next);
break; break;
case 'c': case 'c':
c = va_arg(args, int); _putchar(va_arg(args, int));
write(1, &c, 1);
break; break;
case '%': /*add 1 byte*/ case '%': /*add 1 byte*/
break; break;