refactor the case of c and moved fmt+=2
This commit is contained in:
9
printf.c
9
printf.c
@@ -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
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -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);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user