Can any body help me in converting a double value e.g. 0.000015 to string format in Xcode. so that i may use it as a string. In visual C++ we have to_string function but in Xcode it doesnt works. Regards
2 Answers
If you have a compiler supporting C++11, then std::to_string() is what you want.
1 Comment
khan
thanks but i used the upper answer, as in this case when i change it to c++11 it give me some other errors...so i used the first one...thanks and regards
You can make your 'homebrew' to_string() function very easy using std::stringstream:
template<typename T>
std::string to_string(T value)
{
std::ostringstream oss;
oss << value;
return oss.str();
}
1 Comment
khan
Thanks alot Bro... It worked, Sorry for late replying...just tried it now... thanks
std::ostringstream!operator>>()for any primitive type as usual!