开发者

Aligning text to the right in the C++ console

开发者 https://www.devze.com 2023-01-18 06:56 出处:网络
How do I format my console 开发者_高级运维output so that it\'s aligned to the right in C++? Use the manipulator flag std::right

How do I format my console 开发者_高级运维output so that it's aligned to the right in C++?


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;
}
0

精彩评论

暂无评论...
验证码 换一张
取 消