September 26th, 2003, 01:27 PM
Problems with C++ itoa() function
This is what I am trying to do, assign an integer to a string so for instance:
and I want myStr to have "5". So I am using the "itoa()" function of the format:
char* itoa( int value,
int radix );
and I know that that I am implementing it properly. I am running two compilers, Metrowerks code warrior on windows and G++ on Linux, so when I compile the code on the windows machine it works fine but on the Linux machine (which is my first priority) I get this error:
implicit declaration of function `int itoa(...)'
What am I doing wrong? I googled quite a bit and found some people saying that it might be a bug, but that they werent sure. so is there a way that I can use that function in G++?
September 26th, 2003, 01:42 PM
itoa() is a non-standard function. Use sprintf() instead :D. If you want to go the C++ way, you might also want to consider the strstream class
Up the Irons
What Would Jimi Do? Smash amps. Burn guitar. Take the groupies home.
"Death Before Dishonour, my Friends!!" - Bruce D ickinson, Iron Maiden Aug 20, 2005 @ OzzFest
Down with Sharon Osbourne
"I wouldn't hire a butcher to fix my car. I also wouldn't hire a marketing firm to build my website." - Nilpo
September 27th, 2003, 02:06 AM
MyString should now hold 5
using namespace std;
int MyInt = 5;
MyStream << MyInt << ends;
MyString = MyStream.str();