返回要读取的下一个字符。
int_type peek( );
返回值
要读取的下一个字符。
备注
无格式的输入函数提取元素,如果可能,就像通过返回 rdbuf ->sgetc。 否则,它将返回 traits_type::。eof
示例
// basic_istream_peek.cpp
// compile with: /EHsc
#include <iostream>
using namespace std;
int main( )
{
char c[10], c2;
cout << "Type 'abcde': ";
c2 = cin.peek( );
cin.getline( &c[0], 9 );
cout << c2 << " " << c << endl;
}
abcdeabcdeType
FakePre-dc4520f56458419b8367b2b7a2000ba4-9a66dc998e4f41a8892a108993f08e6c
要求
页眉: <istream>
命名空间: std