Most C++ beginners don't know how to align text in C++ console output. This tip will help:
-Left alignment: to align the output text left, you need to use the left keyword.
-Right alignment: to align the output text right, you need to use the right keyword.
cout<<right<<setw(50)<<setfill('*')<<"programming of C++"<<endl;
The setw(num_chars) function is used to set the width of the text to be output on the console window. If the length of output text is less than the width specified by the setw function, you can fill the blank spaces by any character that you like by using the setfill(character) function. You need to include iomanip header file to use the setw and setfill functions.
Posted by: Dara | post date: 10-23-2012 | Subject: C++ Programming Language
This website intents to provide free and high quality tutorials, examples, exercises and solutions, questions and answers of programming and scripting languages: