rectangletangle
rectangletangle

Reputation: 52911

Aligning text to the right in the C++ console

How do I format my console output so that it's aligned to the right in C++?

Upvotes: 0

Views: 10192

Answers (1)

Gabe
Gabe

Reputation: 50475

Use the manipulator flag std::right

Example

or

This works...

#include<iostream>
using std::cout;
using std::endl;


#include<iomanip>
using std::setw;

int main(){

 int x = 12345;

 cout << "Blah Blah Blah" << endl << setw(80) <<  x << endl;

 system("pause");

 return 0;
}

Upvotes: 5

Related Questions