I am currently writing a coffee shop program, and I want my output for monetary values to be lined up and always in the same spot, even if the characters prior to them are large, but I am not sure how to do this. I know of setw() and setfill(), and those are the only modifiers I have played around with. Any help would be appreciated. This an excerpt from the code. It takes the items purchased, and then returns the totals. Setw looks great, when it is all 0's... and the items before do not change...
To make it easier for you to determine how the lengths should be, copy and paste Ounces of coffee beans sold = to this website http://string-functions.com/length.aspx to get the string length of the longest string you are going to output.
Will the place of the dollar amounts change if the quantity sold value increases in size, because that was the problem I was having. I also placed all the fixed showpoint and set precision stuff in the lines itself, because I do not want the quantity in .00, otherwise I would have placed it at the beginning.
Note that this relies on the standard library implementation having more than mere token support for locales.
(In other words, with the GNU library, this won't work on any platform other than Linux.)
I ended up just breaking the two apart, since the values are unpredictable, and something is always out of format. Even though if everything isn't the same because of an extra digit, they are all relatively inline, and I can live with that.