convert string to Currency

How to convert string to currency type.
Not sure what you mean by currency type.
Do you mean adding a currency's symbol to a string?

eg:
if you have a string with "56.09" in it, then you make it "£56.09"?

Explain more about what you mean by that.

Aceix.
You may need to format the string.
Please do not post duplicates.
http://www.cplusplus.com/forum/windows/100724/
Dear Aceix,
thanx for your valuable reply. yeah i want to do exactly as according to your example. how it is possible. thanx in advance.
1
2
3
std::string str1 = "56.09";
std::string str2 = "£" + str1;
std::cout << str2 << std::endl; // prints £56.09 
Last edited on
if your compiler is sufficiently new, you can use std::put_money from <iomanip>
http://en.cppreference.com/w/cpp/io/manip/put_money
Last edited on
Topic archived. No new replies allowed.