basic_istream::ignore

導致許多項目從目前的讀取位置略過。

basic_istream<Elem, Tr>& ignore(
    streamsize _Count = 1,
    int_type _Delim = traits_type::eof( )
);

參數

  • _Count
    略過的項目數目 (從目前的讀取位置。

  • _Delim
    ,則為,如果發生在計數之前,會 ignore 返回並允許任何項目,則會讀取之後的 _Delim 的項目。

傳回值

資料流 (*this)。

備註

未格式化的輸入函數捕捉 _Count 項目並捨棄。,不過,如果 _Count 等於 numeric_limits<int>::max它選擇性地接受為大。擷取在舊停止檔案結尾或項目上 _Ch 這類 traits_type::to_int_type(_Ch) 等於也會擷取) 的 _Delim (。函式會傳回 *this

範例

// basic_istream_ignore.cpp
// compile with: /EHsc
#include <iostream>
int main( ) 
{
   using namespace std;
   char chararray[10];
   cout << "Type 'abcdef': ";
   cin.ignore( 5, 'c' );
   cin >> chararray;
   cout << chararray;
}
  abcdef
  abcdef
Name)

需求

標題: <istream>

命名空間: std

請參閱

參考

basic_istream Class

iostream 程式設計

iostreams 慣例