// about setw() #include <iostream> #include <iomanip> #include <cstring> using namespace std; int main() { string name = "wangyang"; // generate a string cout << setiosflags(ios::right) << setfill('a') << setw(20) << name << endl; // control the word count, the alignment, the fill return 0; }