setw from left o_O

Oct 22, 2015 at 1:05pm
I know this is a bit of weird question but please bear with me....

I am using setw to output my details nicely and it looks somewhat like this


  1            name             goodman  
  2    another name      anothergoodman
  3    again a name    again a good guy


But I want the setw to set it towards right somewhat like this


  1    name            goodman  
  2    another name    anothergoodman
  3    again a name    again a good guy


What shall I do?
Last edited on Oct 22, 2015 at 1:50pm
Oct 22, 2015 at 1:10pm
Last edited on Oct 22, 2015 at 1:11pm
Oct 22, 2015 at 1:11pm
I am confused: The top example has the fields shifted to the right; while the bottom example has them shifted to the left. Please try again.
Oct 22, 2015 at 1:33pm
closed account (E3h7X9L8)
add in the setw() argument the sum of difference you want between the words of a line and the length of the string

the default flag for output is right so the output is padded to the field width by inserting fill characters at the beginning of the line
Oct 22, 2015 at 1:47pm
@leryss
leryss wrote:
add in the setw() argument the sum of difference you want between the words of a line and the length of the string


Didn't got that one. could you please give me a link/example?


EDIT:- edited title from setw from right to setw from left... (I am getting confused with left and right :D )
Topic archived. No new replies allowed.