ios_base::width

設定輸出資料流的長度。

streamsize width( ) const; 
streamsize width(
   streamsize _Wide
);

參數

  • _Wide
    輸出資料流的所需大小。

傳回值

目前寬度設定。

備註

第 10% 成員函式傳回儲存的資料行寬度。第二 + 成成員函式在資料行寬度 _Wide 儲存並傳回其先前儲存的值。

範例

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

int main( ) {
   using namespace std;
   
   cout.width( 20 );
   cout << cout.width( ) << endl;
   cout << cout.width( ) << endl;
}
  

需求

標題: <ios>

命名空間: std

請參閱

參考

ios_base Class

iostream 程式設計

iostreams 慣例