convert string to Currency

Apr 30, 2013 at 9:16am
How to convert string to currency type.
Apr 30, 2013 at 9:21am
Not sure what you mean by currency type.
Apr 30, 2013 at 9:40am
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.
Apr 30, 2013 at 9:41am
You may need to format the string.
Apr 30, 2013 at 9:45am
Please do not post duplicates.
http://www.cplusplus.com/forum/windows/100724/
Apr 30, 2013 at 10:32am
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.
Apr 30, 2013 at 10:35am
1
2
3
std::string str1 = "56.09";
std::string str2 = "£" + str1;
std::cout << str2 << std::endl; // prints £56.09 
Last edited on Apr 30, 2013 at 10:35am
Apr 30, 2013 at 11:17am
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 Apr 30, 2013 at 11:20am
Topic archived. No new replies allowed.