So I am writing a program, and need to use some formatting to pretty up the output. Right now, the way I write it is like this (as an example):
cout << "|" << setfill('=') << setw(40) << "|" << endl;
cout << "| What is your name?: ";
cin >> userName;
cout << setfill(' ') << setw(40 - 21 - userName.size()) << "|" << endl;
cout << "|" << setfill('=') << setw(40) << "|" << endl;
What this should be outputting is this (the user's input is in all-caps):
|========================================|
| What is your name?: ALARIC |
|========================================|
but what I get is this:
|========================================|
| What is your name?: ALARIC
|
|========================================|
is there a way to solve this, and/or what am I doing wrong?