 |
C++Talk.NET C++ language newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
jack Guest
|
Posted: Wed Feb 23, 2005 4:29 pm Post subject: The itoa function can not be used in g++,right? |
|
|
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
|
|
| Back to top |
|
 |
Eric Lilja Guest
|
Posted: Wed Feb 23, 2005 5:22 pm Post subject: Re: The itoa function can not be used in g++,right? |
|
|
"jack" wrote: news:1109176146.819886.266000 (AT) l41g2000cwc (DOT) googlegroups.com...
| Quote: | 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
|
|
| Back to top |
|
 |
Victor Bazarov Guest
|
Posted: Wed Feb 23, 2005 5:26 pm Post subject: Re: The itoa function can not be used in g++,right? |
|
|
jack wrote:
| Quote: | 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.
|
|
| Back to top |
|
 |
jack Guest
|
Posted: Sat Feb 26, 2005 4:27 pm Post subject: Re: The itoa function can not be used in g++,right? |
|
|
thank you!
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|