std::basic_filebuf<CharT,Traits>:: showmanyc
|
protected
:
virtual std:: streamsize showmanyc ( ) |
(可选) | |
若已实现,返回文件中待读取的剩余字符数。
目录 |
返回值
可从文件中读取的字符数量,若到达文件末尾则为 - 1 。
注释
此函数为可选实现。若未提供具体实现,该函数将返回 0 (因为会调用基类版本 std :: basic_streambuf :: showmanyc )。
无论是否实现,当获取区域为空时,该函数通常会被 std :: basic_streambuf :: in_avail 调用。
该函数名称代表“ s tream: how many c haracters?”,因此应读作“ S how many C ”,而非“show many C”。
示例
用于检测
showmanyc()
是否已在
std::filebuf
中实现的验证测试。
#include <fstream> #include <iostream> struct mybuf : std::filebuf { using std::filebuf::showmanyc; }; int main() { mybuf fin; fin.open("main.cpp", std::ios_base::in); std::cout << "showmanyc() returns " << fin.showmanyc() << '\n'; }
可能的输出:
showmanyc() returns 254
参见
|
获取输入区域中立即可用的字符数量
(
std::basic_streambuf<CharT,Traits>
的公开成员函数)
|
|
|
提取已可用的字符块
(
std::basic_istream<CharT,Traits>
的公开成员函数)
|