previous | start | next

How to ...: 3

How can you print a line of 55 "-" without typing all 55 characters?

When an output value needs fewer character positions than the output field, the value is padding with the 'fill' character either on the left or on the right depending on the justification desired.

The fill character, by default, is a blank.

But you can change the fill character. For example, you can make the fill character be '-'.

Then to print 55 '-' characters:

cout.fill('-');
cout << setw(55) << "" << endl;
cout.fill(' ');


        
     


previous | start | next