Connecting Tech Pros Worldwide Help | Site Map

itoa function in gcc

Moritz Beller
Guest
 
Posts: n/a
#1: Jul 22 '05
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
Victor Bazarov
Guest
 
Posts: n/a
#2: Jul 22 '05

re: itoa function in gcc


Moritz Beller wrote:[color=blue]
> Is there an equivalent to Visual C++'s itoa function in gcc?[/color]

Gcc newsgroup is spelled gnu.gcc.help.

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

Victor
tom_usenet
Guest
 
Posts: n/a
#3: Jul 22 '05

re: itoa function in gcc


On Wed, 18 Aug 2004 18:08:48 +0200, Moritz Beller
<momo.beller.No-Spam@t-online.de> wrote:
[color=blue]
>Hello!
>
>Is there an equivalent to Visual C++'s itoa function in gcc?[/color]

sprintf.

Tom
Niels Dekker - no reply address
Guest
 
Posts: n/a
#4: Jul 22 '05

re: itoa function in gcc


Moritz Beller wrote:[color=blue]
>
> Is there an equivalent to Visual C++'s itoa function in gcc?[/color]

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
Moritz Beller
Guest
 
Posts: n/a
#5: Jul 22 '05

re: itoa function in gcc


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
Closed Thread


Similar C / C++ bytes