There are many methods available. You can use itoa, ltoa etc. to convert numbers to char*. However the following method using stringstream can convert any type of number to std::string.
#include <sstream> using namespace std; int main() { int No = 140; // Or you can use float No = 10.5f stringstream StrStream; StrStream << No; string MyString = StrStream.str(); return 0; }
The resulting MyString contains the value of No as string.
September 2, 2008 at 1:07 pm
[...] Click to see how to convert number to string [...]