Formatting Output
- endl is a special word used with cout that designates a new line (carriage return/line feed); causes the next output to be displayed on the next line
- You can use manipulators to control the look of your output; #include <iomanip.h>
- A common one is setw(size); data will be right justified in a field 'size' characters wide
- Literal strings and characters can contain additional formatting characters (e.g. carriage returns "\r", formfeeds "\f" , tabs "\t", even a bell "\a")
These statements are equivalent;
cout << "Hello\n";
cout << "Hello" << endl;
- The best way to find out how the manipulators work is to try them yourself
Next page
Previous page
Go to Lesson 4 index.