right in iomanip misfunctions

I've always tried using right in manipulating the ostream object cout, but it has never worked in my whole life! Even on the most basic Hello world programme?

I need help. This is the code:
1
2
3
4
5
6
7
8
9
10
11
#include <iostream>
#include <iomanip>

using namespace std;

int main()
{
    cout<<right<<"Hello World!";
    cin.get();
    return 0;
}
Set the width first
1
2
3
4
5
6
7
8
9
10
11
#include <iostream>
#include <iomanip>

using namespace std;

int main()
{
	cout<<setw(20)<<right<<"Hello World!\n";
	cout<<setw(20)<<left<<"Hello World!\n";
	return 0;
}
Last edited on
Thank you very much it WORKS!

1
2
3
4
5
6
7
8
9
10
11
#include <iostream>
#include <iomanip>

using namespace std;

int main()
{
    cout<<setw(80)<<right<<"Hello World!";
    cin.get();
    return 0;
}
Topic archived. No new replies allowed.