[bglug] conversione int->char[] [OT?]

Al al@bglug.it
Mar 30 Nov 2004 19:44:37 CET


Cosi' scrisse Dario:

> Sono un p̣ nei casini, se qualcuno mi dà dei buoni
> consigli provo a scrivere una funzione che me le converta carattere per
> carattere. A dire la verità sono nelle panne pure se devo convertire un
> intero in carattere...

Questo e' facile, man ascii. Come vedi i numeri da 0 a 9 hanno codici
ASCII compresi tra 48 e 57, quindi e' sufficiente un

int  i = 3
char c = i + 48;

Non devi fare altro che convertire in questo modo ogni singola cifra del
numero.


Al


-- 

"At a speed of 1 Mbit/s, a maximum cable length of about 40 meters can be
used. This is because the arbitration scheme requires that the wave front
of the signal can propagate to the most remote node and back again before
the bit is sampled. In other words, the cable length is restricted by the
speed of light. A proposal to increase the speed of light has been consi-
dered but was turned down because of its inter-galactic consequences."


Maggiori informazioni sulla lista bglug