Today, I learned about setfill() and other methods in #include<iomanip>, so I have a practice with using #include<iomanip>.
I want to print this on the console:
+-------------------------+ | Iomanip Examples | +-------------------------+
So I wrote this code:
cout << '+' << setfill('-') << setw(25) << '+' << endl;
cout << setw(26) << internal << "Iomanip Examples" << endl;
cout << '+' << setfill('-') << setw(25) << '+' << endl;
but my console printed this:
+---------------------------+ //It's okay. ------Iomanip Examples //nope.. +---------------------------+
I think when I use setfill('-'), the output stream is filled with '-' character in the empty spaces.
How can I solve this problem?
you again need to use
setfill(' ')for the second line as in your case. once we usesetfill()it will set for all-time in program where we usesetw().