right

原因不是宽度的文本相同,如宽度与输出出现在右边距中的流刷新。

ios_base& right( 
   ios_base& _Str 
);

参数

  • _Str
    引用类型到 ios_base对象,或者从 ios_base继承的类型。

返回值

为_Str 派生的对象的引用。

备注

left 来修改文本的对齐方式。

操控程序有效调用 _Str.setf(ios_base::rightios_base::adjustfield),然后返回 _Str。

示例

// ios_right.cpp
// compile with: /EHsc
#include <iostream>

int main( ) 
{
   using namespace std;
   double f1= 5.00;
   cout << f1 << endl;
   cout.width( 20 );
   cout << f1 << endl;
   cout.width( 20 );
   cout << left << f1 << endl;
   cout.width( 20 );
   cout << f1 << endl;
   cout.width( 20 );
   cout << right << f1 << endl;
   cout.width( 20 );
   cout << f1 << endl;
}
  

要求

页眉: <ios>

命名空间: std

请参见

参考

iostream 编程

iostreams 约定