By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,332 Members | 1,427 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,332 IT Pros & Developers. It's quick & easy.

itoa function in gcc

P: n/a
Hello!

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

best regards
Moritz Beller
--
web http://www.4momo.de
mail momo dot beller at t-online dot de
gpgkey http://gpg.notlong.com
Jul 22 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Moritz Beller wrote:
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
Jul 22 '05 #2

P: n/a
On Wed, 18 Aug 2004 18:08:48 +0200, Moritz Beller
<mo*****************@t-online.de> wrote:
Hello!

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


sprintf.

Tom
Jul 22 '05 #3

P: n/a
Moritz Beller wrote:

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
Jul 22 '05 #4

P: n/a
Hey,

many thanks to all of you!

best regards
Moritz Beller
--
web http://www.4momo.de
mail momo dot beller at t-online dot de
gpgkey http://gpg.notlong.com
Jul 22 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.