Output formatting assistance

Full disclosure: I'm working on a school assignment at the moment. While I have figured out the majority of the assignment one problem has continued to vex me. This is a fragment of the code that I am working on.

1
2
3
4
5
6
7
  cout << startYear
       << setw(6)
       << MonthName( startMonth )
       << setw(25)
       << fixed << showpoint << setprecision(2)
       << totalAmt << endl;


For clarification MonthName( startMonth ) is a user-defined function that returns the month.

The output is currently showing as (without dots, last character of each month lines up):

2015 March........................500.00
2015 April........................1013.00
2015 May.........................2050.00

However, I need the output to be (without dots, first character of month should line up and the last value of each number):

2015 March..........................500.00
2015 April..........................1013.00
2015 May...........................2050.00

I can get either the month to line up correctly or the numbers to line up, but I can't get both. Does anybody have any pointers on how to handle this particular issue?
Last edited on
Take advantage of std::left and std::right:
http://ideone.com/w7l81F
Last edited on
LB,

Thanks. That solved it for me. I appreciate the quick response.
Topic archived. No new replies allowed.