I would like to split integer into digits and then convert each digit to ASCII (in C programming language).
Example:
int x = 0xABC
/* split integers */
int x1 = 0xA
int x2 = 0xB
int x3 = 0xC
/* convert integers to ASCII */
int x1 = 0x41
int x2 = 0x42
int x3 = 0x43
Also, if the integer is only 2 digits long (hex), I still need 3 splits:
int y = 0xBC
/* split integers */
int y1 = 0x0
int y2 = 0xB
int y3 = 0xC
.
.
.
Many thanks in advance!
Use math: x = x₁ · 16² + x₂ · 16 + x₃
Use a lookup table to see what the digit is:
I won’t give you a full solution since it’s a homework related question.
Full solution (less easy to understand):