名前空間
変種
操作

std::setw

提供: cppreference.com
< cpp‎ | io‎ | manip

 
 
入力/出力ライブラリ
I / Oのマニピュレータ
CスタイルのI / O
バッファ
Original:
Buffers
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
basic_streambuf
basic_filebuf
basic_stringbuf
strstreambuf(廃止予定)
ストリーム
Original:
Streams
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
抽象化
Original:
Abstractions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
ios_base
basic_ios
basic_istream
basic_ostream
basic_iostream
ファイルI / O
Original:
File I/O
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
basic_ifstream
basic_ofstream
basic_fstream
文字列I / O
Original:
String I/O
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
basic_istringstream
basic_ostringstream
basic_stringstream
アレイのI / O
Original:
Array I/O
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
istrstream(廃止予定)
ostrstream(廃止予定)
strstream(廃止予定)
タイプ
Original:
Types
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
streamoff
streamsize
fpos
エラーカテゴリインターフェース
Original:
Error category interface
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
iostream_category(C++11)
io_errc(C++11)
 
入力/出力マニピュレータ
浮動小数点の書式
Original:
Floating-point formatting
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
整数フォーマット
Original:
Integer formatting
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
ブールの書式
Original:
Boolean formatting
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
boolalpha
noboolalpha
フィールド幅と塗りつぶしコントロール
Original:
Field width and fill control
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
setfill
setw
その他の書式
Original:
Other formatting
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
空白処理
Original:
Whitespace processing
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
出力がフラッシュします
Original:
Output flushing
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
ステータスフラグ操作
Original:
Status flags manipulation
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
時間とお金のI / O
Original:
Time and money I/O
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
get_money(C++11)
get_time(C++11)
put_money(C++11)
put_time(C++11)
 
Defined in header <iomanip>
/*unspecified*/ setw( int n );
式で使用される場合out << setw(n)またはin >> setw(n)、ストリームのwidthパラメータを設定outまたはin正確にn。それがゼロ( "不特定"という意味)にリセットされ、ストリームのwidthフィールドの値によって影響される次の入力または出力操作..:この値は、 "粘着性"ではありません
Original:
When used in an expression out << setw(n) or in >> setw(n), sets the width parameter of the stream out or in to exactly n. This value is not "sticky": the next input or output operation that is affected by the value of the stream's width field, resets it to zero (meaning "unspecified").
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

目次

[編集] パラメータ

n -
幅の新しい値
Original:
new value for width
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[編集] 値を返します

不特定の型のオブジェクトを返すような場合strタイプの出力ストリームの名前ですstd::basic_ostream<CharT, Traits>またはstd::basic_istream<CharT, Traits>、式str << setw(n)またはstr >> setw(n)次のコードが実行されたかのように動作します
Original:
Returns an object of unspecified type such that if str is the name of an output stream of type std::basic_ostream<CharT, Traits> or std::basic_istream<CharT, Traits>, then the expression str << setw(n) or str >> setw(n) behaves as if the following code was executed:
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

str.width(n);

[編集]

#include <sstream>
#include <iostream>
#include <iomanip>
int main()
{
        std::cout << "no setw: " << 42 << '\n'
                  << "setw(6): " << std::setw(6) << 42 << '\n';
        std::istringstream is("hello, world");
        char arr[10];
        is >> std::setw(6) >> arr;
        std::cout << "Input from \"" << is.str() << "\" with setw(6) gave \"" << arr << "\"\n";
}

Output:

no setw: 42
setw(6):     42
Input from "hello, world" with setw(6) gave "hello"

[編集] も参照してください

manages field width
(パブリックメンバ関数of std::ios_base) [edit]
埋め込み文字を変更します
Original:
changes the fill character
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(関数テンプレート) [edit]