int to string conversion

Roberto Alsina ralsina at unl.edu.ar
Fri Feb 11 20:13:36 GMT 2000


On Sat, 12 Feb 2000, Tilo Riemer wrote:

> Martin Wiebusch wrote:
> > 
> > Hi,
> > i was just wondering whether there is a function to convert integer
> > values to strings in any of the libaries. I already tried itoa, Itoa and
> > IntToStr. I also noticed there ist an Itoa function defined in the
> > Integer.h header. But I don't really need an Integer class, just a
> > little function to convert usual int variables into strings.
> use printf or sprintf...

Keep in mind that if you use sprintf, you need to allocate enough space in
the buffer for the string conversion of the number.

So: always use careful formatting, specially with user provided data, or
your program can crash.

Just imagine someone feeding a 65537 digit integer number into it :-)

 ("\''/").__..-''"`-. .         Roberto Alsina
 `9_ 9  )   `-. (    ).`-._.`)  ralsina at unl.edu.ar
 (_Y_.)' ._   ) `._`.  " -.-'   Centro de Telematica
  _..`-'_..-_/ /-'_.'           Universidad Nacional del Litoral
(l)-'' ((i).' ((!.'             Santa Fe - Argentina
                                KDE Developer (MFCH)
The stone age didn't end for a lack of stone" Firoz Rasul





More information about the KDevelop mailing list