fix printing of 0 integer

This commit is contained in:
cy384 2020-07-23 19:58:25 -04:00
parent 9b319d7b77
commit 86054bae08
1 changed files with 6 additions and 0 deletions

View File

@ -114,6 +114,12 @@ void print_int(int d)
char buffer[12] = {0}; char buffer[12] = {0};
int i = 10; int i = 10;
if (d == 0)
{
buffer[0] = '0';
i = -1;
}
for (; d > 0; i--) for (; d > 0; i--)
{ {
buffer[i] = itoc[d % 10]; buffer[i] = itoc[d % 10];