refactor the case of c and moved fmt+=2

This commit is contained in:
LinlyBoi
2023-08-21 13:10:04 +03:00
parent c90057710a
commit ccdc076362
2 changed files with 5 additions and 6 deletions

View File

@@ -34,18 +34,17 @@ int _printf(const char *format, ...)
buffer = _strcpy(buffer, next); buffer = _strcpy(buffer, next);
BUFF_SIZE = _strlen(buffer); BUFF_SIZE = _strlen(buffer);
buff_idx += _strlen(next); buff_idx += _strlen(next);
fmt_idx += 2;
break; break;
case 'c': /* add 1 byte and i++ */ case 'c': /* add 1 byte and i++ */
c = va_arg(args, int); c = (char) va_arg(args, int);
*(buffer + buff_idx + 1) = (char) c; *(buffer + buff_idx) = c;
BUFF_SIZE = _strlen(buffer); BUFF_SIZE += 1;
buff_idx += 1; buff_idx += 1;
fmt_idx += 2;
break; break;
case '%': /*add 1 byte*/ case '%': /*add 1 byte*/
break; break;
} }
fmt_idx += 2;
} }
else else
{ {

View File

@@ -11,5 +11,5 @@ int main(void)
char c = 97; char c = 97;
_printf("cat: %c", c); _printf("cat: %c", c);
return (1); return (0);
} }