Format of Output and put_money

I am trying to format my function so that the output has a space between the headers and using put_money a dollar sign in front of the values but when I try this it does not work.Any help? Here is my code:

void PrintFileContents(std::ifstream &str)
// Put your code here
std::string name;
double savings;
double credit;
SetInputStreamPos(str, 0);
std::cout << "Name" << std::setw(12) << "Savings" << std::setw(12) << "Credit " << std::endl;
while (str >> name >> savings >> credit )
std::cout << name << std::setw(12) << put_money(savings) << std::setw(12) << put_money(credit) << "\n";

1. Define "does not work"
2. What do you expect the line "std::locale();" to do? Did you mean std::cout.imbue(std::locale("")); perhaps?

Also, to get the dollar sign, you need to drop in an std::showbase before using std::put_money
Last edited on
Dollar signs before the amounts do not appear when I do this. Also the values do not line up with the headings.
Topic archived. No new replies allowed.