itoa function

Write here if you have problems with your C source code

Moderator: Board moderators

Post Reply
click xx
New poster
Posts: 10
Joined: Mon May 13, 2002 9:42 am

itoa function

Post 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?
Stefan Pochmann
A great helper
Posts: 284
Joined: Thu Feb 28, 2002 2:00 am
Location: Germany
Contact:

Post 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]
click xx
New poster
Posts: 10
Joined: Mon May 13, 2002 9:42 am

Post by click xx »

Thanks for your help!I'll try it
igpuebla
New poster
Posts: 3
Joined: Sat Nov 08, 2003 2:05 am
Location: Spain

Post by igpuebla »

Yea, it works :wink:
[/cpp]
igpuebla
New poster
Posts: 3
Joined: Sat Nov 08, 2003 2:05 am
Location: Spain

Post by igpuebla »

Yea, it works :wink:
[/cpp]
deddy one
Experienced poster
Posts: 120
Joined: Tue Nov 12, 2002 7:36 pm

Post 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..
Post Reply

Return to “C”