You can use sprintf
to do it, or maybe snprintf
if you have it:
char str[ENOUGH];
sprintf(str, "%d", 42);
Where the number of characters (plus terminating char) in the str
can be calculated using:
(int)((ceil(log10(num))+1)*sizeof(char))
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…