名前空間
変種
操作

std::basic_istream::getline

提供: 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)
 
basic_istream& getline( char_type* s, std::streamsize count );
(1)
basic_istream& getline( char_type* s, std::streamsize count, char_type delim );
(2)
1)
行末(getline(s, count, widen(’\n’))に相当)までストリームから抽出文字
Original:
Extracts characters from stream until the end of line (equivalent to getline(s, count, widen(’\n’)))
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
2)
を抽出し、指定された区切り文字まで、ストリームから文字.
Original:
Extracts characters from stream until the specified delimiter.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
UnformattedInputFunctionとして動作します。監視オブジェクトを構築し、確認した後、*thisから文字を抽出し、最初の要素は、次のいずれかが発生するまでsで指される配列の連続した​​場所にそれらを格納されている:(示されている順序でテスト済み)
Original:
Behaves as UnformattedInputFunction. After constructing and checking the sentry object, extracts characters from *this and stored them in successive locations of the array whose first element is pointed to by s until any of the following occurs: (tested in the order shown)
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 (in which case setstate(eofbit) is executed)
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • 次に使用可能な文字はcTraits::eq(c, delim)によって決定されるように、区切り文字です。区切り文字は、抽出された(basic_istream::get()とは違って)とgcount()にカウントしますが、保存されていないされている.
    Original:
    the next available character c is the delimiter, as determined by Traits::eq(c, delim). The delimiter is extracted (unlike basic_istream::get()) and counted towards gcount(), but is not stored.
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • count-1文字(setstate(failbit)が実行される場合に)抽出された.
    Original:
    count-1 characters have been extracted (in which case setstate(failbit) is executed).
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
関数が文字を抽出していない場合(例えば、もしcount < 1)、setstate(failbit)実行され.
Original:
If the function extracts no characters (e.g. if count < 1), setstate(failbit) is executed.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
count>0場合、どのような場合でも、それは、その後、次の連続した​​配列の位置と更新CharT()にnull文字gcount()を格納.
Original:
In any case, if count>0, it then stores a null character CharT() into the next successive location of the array and updates gcount().
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

目次

[編集] ノート

条件#2が条件#3、正確にバッファに合う入力行の前にテストされているので、failbitをトリガしません.
Original:
Because condition #2 is tested before condition #3, the input line that exactly fits the buffer, does not trigger failbit.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
終端文字が抽出された文字としてカウントされるため、空の入力行はfailbitをトリガしません.
Original:
Because the terminating character is counted as extracted character, empty input line does not trigger failbit.
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 extracted but not stored.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[編集] 値を返します

*this

[編集]

#include <iostream>
#include <sstream>
#include <vector>
#include <array>
 
int main()
{
    std::istringstream input("abc|def|gh");
    std::vector<std::array<char, 4>> v;
 
    for(std::array<char, 4> a; input.getline(&a[0], 4, '|'); ) {
        v.push_back(a);
    }
 
    for(auto& a : v) {
        std::cout << &a[0] << '\n';
    }
}

Output:

abc
def
gh

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

文字列にI / Oストリームからデータを読み取る
Original:
read data from an I/O stream into a string
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(機能)
抽出は、データをフォーマットします
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
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 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]