snextc
描述 (Description)
它用于将受控输入序列的当前位置前进到下一个字符,并返回下一个字符。
声明 (Declaration)
以下是std :: basic_streambuf :: snextc的声明。
int_type snextc();
参数 (Parameters)
没有
返回值 (Return Value)
它返回受控输入序列的下一个位置的字符,使用成员traits_type :: to_int_type转换为int_type类型的值。
异常 (Exceptions)
Basic guarantee - 如果抛出异常,则流缓冲区处于有效状态。
数据竞争 (Data races)
它修改了流缓冲区对象。
例子 (Example)
在下面的例子中解释了std :: basic_streambuf :: snextc。
#include <iostream>
#include <fstream>
int main () {
std::ifstream istr ("sample.txt");
if (istr) {
std::streambuf * pbuf = istr.rdbuf();
do {
char ch = pbuf->sgetc();
std::cout << ch;
} while ( pbuf->snextc() != std::streambuf::traits_type::eof() );
istr.close();
}
return 0;
}