Converting a number to a std::string
Converting a number to a std::string
There are no obvious functions in pure C++ (lots in C!) to convert a number into an std::string.
The way to do this is by using a
stringstream
, i.e.
#include<iostream> #include<sstream> std::string NumToString(double num) { std::stringstream s; s << num; return s.str(); } int main() { double anum=3.141592; std::string str = NumToString(anum); std::cout << "Here is our string: "<< str << std::endl; }
19 Sep 13, 6:42PM
hello everyone
welcome to this forum.Here u find all your questions and get your answers.
right now i am unable to find your answer.If you want to see c programming you can go through this.
---------
[url=http://www.javatutorials.tk] C Programming [/url]