名前空間
変種
操作

std::basic_istream::get

提供: cppreference.com
< cpp‎ | io‎ | basic istream

 
 
入力/出力ライブラリ
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)
 
std::basic_istream
グローバルオブジェクト
Original:
Global objects
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
cin
wcin
メンバ関数
Original:
Member functions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
basic_istream::basic_istream
basic_istream::~basic_istream
basic_istream::operator=(C++11)
書式付き入力
Original:
Formatted input
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
basic_istream::operator>>
書式なし入力
Original:
Unformatted input
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
basic_istream::get
basic_istream::peek
basic_istream::unget
basic_istream::putback
basic_istream::getline
basic_istream::ignore
basic_istream::read
basic_istream::readsome
basic_istream::gcount
ポジショニング
Original:
Positioning
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
basic_istream::tellg
basic_istream::seekg
その他
Original:
Miscellaneous
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
basic_istream::sync
basic_istream::swap(C++11)
メンバークラス
Original:
Member classes
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
basic_istream::sentry
非メンバ関数
Original:
Non-member functions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
operator>>(std::basic_istream)
 
int_type get();
(1)
basic_istream& get( char_type& ch );
(2)
basic_istream& get( char_type* s, std::streamsize count );
(3)
basic_istream& get( char_type* s, std::streamsize count, char_type delim );
(4)
basic_istream& get( basic_streambuf& strbuf );
(5)
basic_istream& get( basic_streambuf& strbuf, char_type delim );
(6)
ストリームからの文字または文字列を抽出.
Original:
Extracts character or characters from stream.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
すべてのバージョンはUnformattedInputFunctionsとして振る舞う。構築し、監視オブジェクトをチェックした後、これらの関数は、次の手順を実行します
Original:
All versions behave as UnformattedInputFunctions. After constructing and checking the sentry object, these functions perform the following:
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
1)
1文字が読み取られ、利用可能であれば、それを返します。それ以外の場合、返品Traits::eof()とセットfailbiteofbit.
Original:
reads one character and returns it if available. Otherwise, returns Traits::eof() and sets failbit and eofbit.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
2)
1文字を読み取り、ch可能な場合にそれを格納します。それ以外の場合は、変更されていないch葉と設定failbiteofbit。この関数はsigned charunsigned char、フォーマットされた文字入力演算子>>とは違って型に過負荷になっていないことに注意してください.
Original:
reads one character and stores it to ch if available. Otherwise, leaves ch unmodified and sets failbit and eofbit. Note that this function is not overloaded on the types signed char and unsigned char, unlike the formatted character input operator>>.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
3)
get(s, count, widen('\n'))と同じ、つまり、count-1が発見されるまでsが指す最も'\n'文字と文字列に格納し、それらをリードすると、.
Original:
same as get(s, count, widen('\n')), that is, reads at most count-1 characters and stores them into character string pointed to by s until '\n' is found.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
4)
最初の要素sによって指された文字配列の連続した​​位置に文字を格納し、それらを読み取ります。文字を抽出し、次のいずれかが発生するまで保存されています
Original:
reads characters and stores them into the successive locations of the character array whose first element is pointed to by s. Characters are extracted and stored until any of the following occurs:
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
  • n-1文字が格納されています
    Original:
    n-1 characters have been stored
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • ファイルの終わり状態は、入力シーケンス(setstate(eofbit)が呼ばれています)で発生します
    Original:
    end of file condition occurs in the input sequence (setstate(eofbit) is called)
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • 次の使用可能な入力文字がcとしてdelimによって決まり、Traits::eq(c, delim)等しい。この文字は(basic_istream::getline()とは違って)抽出されません
    Original:
    the next available input character c equals delim, as determined by Traits::eq(c, delim). This character is not extracted (unlike basic_istream::getline())
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
文字が抽出されなかった場合は、setstate(failbit)呼び出します。いずれにせよ、もしcount>0、ヌル文字(CharT()配列の次の連続した​​場所に格納されている.
Original:
If no characters were extracted, calls setstate(failbit). In any case, if count>0, a null character (CharT() is stored in the next successive location of the array.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
5)
get(strbuf, widen('\n'))が発見されるまで、指定されたbasic_streambufオブジェクトに使用可能な文字を挿入し、それらを読み取ります'\n'と同じ..
Original:
same as get(strbuf, widen('\n')), that is, reads available characters and inserts them to the given basic_streambuf object until '\n' is found.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
6)
与えbasic_streambufオブジェクトによって制御される出力シーケンスに文字を挿入し、それらを読み込んだ文字は、次のいずれかが発生するまでstrbufに抽出し、挿入されます
Original:
reads characters and inserts them to the output sequence controlled by the given basic_streambuf object. Characters are extracted and inserted into strbuf until any of the following occurs:
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
  • ファイルの終わり状態が入力シーケンスで発生
    Original:
    end of file condition occurs in the input sequence
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • に挿入します。出力シーケンスが(その場合には挿入できなかった文字は、抽出されません)
    Original:
    insert into the output sequence fails (in which case the character that could not be inserted, is not extracted)
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • 次の使用可能な入力文字cdelimによって決定されるように、Traits::eq(c, delim)等しい。この文字が抽出されていません.
    Original:
    the next available input character c equals delim, as determined by Traits::eq(c, delim). This character is not extracted.
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • 例外が発生した失敗した(内その場合は例外)がキャッチされ、再スローされません
    Original:
    an exception occurs (in which case the exception is caught and not rethrown)
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
文字が抽出されなかった場合、呼び出しsetstate(failbit).
Original:
If no characters were extracted, calls setstate(failbit).
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
すべてのバージョンに抽出された文字の数にgcount()の値を設定.
Original:
All versions set the value of gcount() to the number of characters extracted.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

目次

[編集] パラメータ

ch -
に結果を書き込むための文字への参照
Original:
reference to the character to write the result to
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
s -
に文字列を格納するための文字列へのポインタ
Original:
pointer to the character string to store the characters to
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
count -
sが指す文字列の大きさ
Original:
size of character string pointed to by s
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
delim -
での抽出を停止するには、文字を区切る。これは抽出されないと保存されません.
Original:
delimiting character to stop the extraction at. It is not extracted and not stored.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
strbuf -
にコンテンツを読むためのストリームバッファ
Original:
stream buffer to read the content to
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[編集] 値を返します

1)
抽出された文字またはTraits::eof()
Original:
the extracted character or Traits::eof()
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

2-6) *this

[編集]

#include <sstream>
#include <iostream>
int main()
{
    std::istringstream s1("Hello, world.");
    char c1 = s1.get(); // reads 'H'
    std::cout << "after reading " << c1 << ", gcount() == " <<  s1.gcount() << '\n';
    char c2;
    s1.get(c2);         // reads 'e'
    char str[5];
    s1.get(str, 5);     // reads "llo,"
    std::cout << "after reading " << str << ", gcount() == " <<  s1.gcount() << '\n';
    std::cout << c1 << c2 << str;
    s1.get(*std::cout.rdbuf()); // reads the rest, not including '\n'
    std::cout << "\nAfter the last get(), gcount() == " << s1.gcount() << '\n';
}

Output:

after reading H, gcount() == 1
after reading llo,, gcount() == 4
Hello, world.
After the last get(), gcount() == 7

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

文字のブロックを抽出します
Original:
extracts blocks of characters
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(パブリックメンバ関数) [edit]
抽出は、データをフォーマットします
Original:
extracts formatted data
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(パブリックメンバ関数) [edit]
文字と文字配列を抽出します
Original:
extracts characters and character arrays
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

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