导致大量的元素读取从当前位置跳过。
basic_istream<Elem, Tr>& ignore(
streamsize _Count = 1,
int_type _Delim = traits_type::eof( )
);
参数
_Count
跳过元素的数量读取从当前位置。_Delim
因此,如果遇到在计数之前,导致返回 忽略 和允许所有元素在 _Delim 之后读取的元素。
返回值
流 (*this)。
备注
无格式的输入函数提取到 _Count 元素并放弃它们。 但是,如果 _Count 等于 numeric_limits<int>::max,该示例随机采用为大。 提取在早期停止文件尾或 **traits_type::**这样 _Ch 元素上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
FakePre-7c7d4a2e84784afab3402482cd0eb7ea-53af7a6b04e54b50b908c371b5f0ee9c
要求
页眉: <istream>
命名空间: std