itoa function

Write here if you have problems with your C source code

Moderator: Board moderators

itoa function

Postby click xx » Fri May 31, 2002 8:57 am

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

Postby Stefan Pochmann » Fri May 31, 2002 11:55 pm

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

Postby click xx » Sat Jun 01, 2002 3:23 pm

Thanks for your help!I'll try it
click xx
New poster
 
Posts: 10
Joined: Mon May 13, 2002 9:42 am

Postby igpuebla » Sat Nov 08, 2003 2:32 am

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

Postby igpuebla » Sat Nov 08, 2003 2:32 am

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

Postby deddy one » Sun Nov 16, 2003 7:02 pm

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..
deddy one
Experienced poster
 
Posts: 120
Joined: Tue Nov 12, 2002 7:36 pm


Return to C

Who is online

Users browsing this forum: No registered users and 0 guests