Cpp - cout Output Strings

Introduction

Strings can be positioned within output fields.

string s("spring flowers "); 
cout << left            // Left-aligned 
     << setfill('?')    // Fill character ? 
     << setw(20) << s ; // Field width 20 

This example outputs the string:

spring  flowers??????

The manipulator right can be used to right-justify the output within the field.