Right Justified Numbers

Apr 15, 2013 at 12:47am
I'm trying to figure out how to output some digits that are all right justified without using setw(). Is that possible? I was working out of Programming Principles and Practice Using C++ and one of the exercises talks about trying to get all the numbers right justified. The problem is that if I put, say, setw(20) but only have 3 digit numbers, then I have all this space in between. So basically what I want to be able to do is this: If I type in 3 digits for value one, and then a two digit number for the rest (ie: cin>>value1>>value2>>value3; where value1 one is 3 digits, and value2 and value3 are 2 digits)
it will output this:
value1: 236
value2: 23
value3: 32

but, if value1 is 23423, then have it output
value1: 23423
value2: 23
value3: 2

okay so those numbers aren't showing up right justified, but you get the idea (I hope)
any help would be appreciated!
Last edited on Apr 15, 2013 at 12:52am
Topic archived. No new replies allowed.