Sezione errata, c'e' la sottosezione "Italian->software"
Comunque,
Ma il valore è sempre di 3 cifre? Se non lo è conviene convertire il numero in stringa (vettore di caratteri) usando ad esempio itoa() oppure la snprintf()
int n=1234;
char buf[6];
snprintf(buf,6,"%d",n); // ora in buf ci saranno i caratteri '1', '2', '3' e '4' nella cella 0,1,2 e 3 rispettivamente
// inoltre in cella 4 c'e' il fine stringa '\0' carattere speciale
As for language: sometimes even when people post in English, it's still hard to understand what they want.
Well, here is my way of doing this sort of thing:
int n = 123;
int leftover = n;
char hund = '0'; char tens = '0'; char ones = '0';
while (leftover >= 100) { leftover -= 100; hund++; }
while (leftover >= 10) { leftover -= 10; tens++; }
ones += leftover;
// now the digits (ASCII format) are in hund, tens, and ones
// If you prefer numbers like 99 as " 99" rather than as "099",
// then do this afterward:
if (hund=='0') {
hund = ' ';
if (tens=='0') tens = ' ';
}
By the way, the number 1 is not the same as the character '1'. Please see: