itoa function in gcc

M

Moritz Beller

Hello!

Is there an equivalent to Visual C++'s itoa function in gcc?

best regards
Moritz Beller
 
V

Victor Bazarov

Moritz said:
Is there an equivalent to Visual C++'s itoa function in gcc?

Gcc newsgroup is spelled gnu.gcc.help.

Instead of 'itoa' use 'sprintf'. Should work on all compilers.

Victor
 
N

Niels Dekker - no reply address

Moritz said:
Is there an equivalent to Visual C++'s itoa function in gcc?

I tried itoa on gcc 3.4.1, and it works! Don't forget to
#include <stdlib.h> Please note that -ansi won't work anymore, because
itoa is non-standard.

Still, if you're doing C++ (not C), why not use boost::lexical_cast?
For example:

#include <string>
#include <boost/lexical_cast.hpp> // From www.boost.org

int main(int argc, char **)
{
std::string str = boost::lexical_cast<std::string>(argc);
// ...
return 0;
}

Also check out "The String Formatters of Manor Farm" by Herb Sutter
(CUJ Nov 2001), at http://www.gotw.ca/publications/mill19.htm


Niels Dekker
www.xs4all.nl/~nd/dekkerware
 

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,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top