The itoa function can not be used in g++,right?

J

jack

I try to use this function in g++,I have include the head file
'cstdlib' and 'stdlib.h',but it still can not be recognized by
compiler? Anyboday knows what is wrong? or Is there a substitution for
this function.
thanks
 
E

Eric Lilja

"jack" wrote: news:[email protected]...
I try to use this function in g++,I have include the head file
'cstdlib' and 'stdlib.h',but it still can not be recognized by
compiler? Anyboday knows what is wrong? or Is there a substitution for
this function.
thanks

It's a non-standard function, offered as a compiler extension on some
systems. Fortunately, you can easily reproduce its behaviour using
stringstreams. If you should happen to code C sometime and you need the
functionality of itoa() you can reproduce its behaviour using sprintf().
That won't be as safe as the C++ version, though, so always use
stringstreams with C++ instead of sprintf().

/ Eric
 
V

Victor Bazarov

jack said:
I try to use this function in g++,I have include the head file
'cstdlib' and 'stdlib.h',but it still can not be recognized by
compiler? Anyboday knows what is wrong? or Is there a substitution for
this function.

There is no substitution. Use 'sprintf' or look around on the web for
'toString' function or something of that sort.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top