Login | Register   
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: C++
Expertise: Intermediate
Mar 5, 2001

Right-Justification of Output


To right justify the output of cout, call the width() function with the size of the output screen (in characters) as an argument. In the following example, the program calls width() to right-justify a number that is displayed on a standard screen of 80 characters:
 
#include <iostream>
using namespace std;
int main()
{
 int var=15;
 cout.width(80);
 cout << var << endl; // right-justified display
}
Danny Kalev
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap