September 18th, 2003, 11:03 AM
double to string C++
Okay, I have another question for yall. I am having a little problem going from double to string.
I am currently saving to a text file then reading it back, but I don't like this away at all. Could you show me an easier way please.
Okay thanks for the help.
No replies found.
Last edited by calculus87; September 18th, 2003 at 12:51 PM.
September 18th, 2003, 02:21 PM
Huh? I interpret you as saying that you want to take the value of a double variable and assign the string representation of that value to a string.
Why not use sprintf?
Or if you insist on a purely C++ solution, then use a string stream:
buf << dNum;
sStr = buf.str(); // .str() returns string object associated with buf
September 19th, 2003, 10:30 AM
Answer to double to string
Okay, that works wonderfully. Thanks alot
using namespace std;
stream << dub; // shove it into the stream
string dubble = stream.str(); // create a string of dub
This message is a natural product made from recycled electrons. The slight
variations in spelling and grammar enhance its individual character and
beauty and in no way are to be considered flaws or defects.