add quick simple integer print function

This commit is contained in:
cy384 2020-07-23 19:45:01 -04:00
parent d8b7b26f17
commit 3c72511444
2 changed files with 17 additions and 0 deletions

View File

@ -107,6 +107,22 @@ void print_char(char c)
}
}
void print_int(int d)
{
char itoc[] = {'0','1','2','3','4','5','6','7','8','9'};
char buffer[12] = {0};
int i = 10;
for (; d > 0; i--)
{
buffer[i] = itoc[d % 10];
d /= 10;
}
print_string(buffer+i+1);
}
void print_string_i(const char* c)
{
print_string(c);

View File

@ -22,6 +22,7 @@ int is_printable(char c);
void print_char(char c);
void print_string(const char* c);
void print_string_i(const char* c);
void print_int(int d);
void set_window_title(WindowPtr w, const char* c_name);