Page 1 of 1

itoa function

Posted: Fri May 31, 2002 8:57 am
by click xx
I used itoa function in my porgram and got compiling error.
The error message is: implicit declaration of function "int itoa(...)''
What does this mean?

Posted: Fri May 31, 2002 11:55 pm
by Stefan Pochmann
That means you probably use micro$oft crap at home, because itoa is not defined in C/C++ as far as I know. Use these instead:

[cpp]
char tmp[20];
sprintf( tmp, "%d", i );
string s = tmp;

ostringstream sout;
sout << i;
string s = sout.str();
[/cpp][/cpp]

Posted: Sat Jun 01, 2002 3:23 pm
by click xx
Thanks for your help!I'll try it

Posted: Sat Nov 08, 2003 2:32 am
by igpuebla
Yea, it works :wink:
[/cpp]

Posted: Sat Nov 08, 2003 2:32 am
by igpuebla
Yea, it works :wink:
[/cpp]

Posted: Sun Nov 16, 2003 7:02 pm
by deddy one
in some problem I need to convert int to string,
and I always use sprintf to do that.

but in several cases I got Time Limit Exceeded.
of course the main problem may not lie on the
sprintf, but rather the algo that I'm using.

but I want to know if there's any other way that
faster than sprintf to convert int to string???????

thx..