convert int to string in c++
-
sorry im new to c++i no this is a simple problem but help would be greatly appreciated convert an int to a string? cheers
-
sorry im new to c++i no this is a simple problem but help would be greatly appreciated convert an int to a string? cheers
_itoa CString::Format sprintf strstream class etc Many different ways
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03 "Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04 Within you lies the power for good - Use it!
Honoured as one of The Most Helpful Members of 2004
-
_itoa CString::Format sprintf strstream class etc Many different ways
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03 "Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04 Within you lies the power for good - Use it!
Honoured as one of The Most Helpful Members of 2004
sorry can you please post the code example int fig = 2; string string1; thanks
-
sorry can you please post the code example int fig = 2; string string1; thanks
try using string streams from sstream.h
int fig = 2; std::string string1; std::ostringstream oss; oss << fig; string1 = oss.str();
-
sorry can you please post the code example int fig = 2; string string1; thanks
int fig = 2; string string1; strstream stream; stream << fig << ends; string1 = stream.str();
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03 "Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04 Within you lies the power for good - Use it!
Honoured as one of The Most Helpful Members of 2004
-
sorry im new to c++i no this is a simple problem but help would be greatly appreciated convert an int to a string? cheers
CString str; int i=5; str.Format("The integer Number is : %d",i);
-
sorry can you please post the code example int fig = 2; string string1; thanks
-
sorry im new to c++i no this is a simple problem but help would be greatly appreciated convert an int to a string? cheers
The fastest method is the following: int i = 5135; char String [64]; // REALLY big number :) _itoa (i, String, 10); Using the other methods discussed are slow and involve the memory manager which will cause all sorts of performance issues. Tim Smith I'm going to patent thought. I have yet to see any prior art.