首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

std::basic_filebuf::showmanyc

protected: virtual std::streamsize showmanyc()

?

?

如果实现,则返回要从文件中读取的字符数。

参数

%280%29

返回值

可用于从文件中读取的字符数,或-1如果到达文件的末尾。

注记

此函数是可选的。如果未实现,此函数将返回?0?%28自基类版本以来std::basic_streambuf::showmanyc获取调用%29。

无论实现与否,此函数通常由std::basic_streambuf::in_avail如果GET区域是空的。

这个函数的名称代表“stream:多少个字符?”,因此它被发音为“Sow Cow C”,而不是“Show多C”。

实现测试,以查看是否为filebuf实现了showmanyc%28%29。

二次

代码语言:javascript
复制
#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';
}

二次

可能的产出:

二次

代码语言:javascript
复制
showmanyc() returns 267

二次

另见

in_avail

obtains the number of characters immediately available in the get area (public member function of std::basic_streambuf)

readsome

extracts already available blocks of characters (public member function of std::basic_istream)

代码语言:txt
复制
 ? cppreference.com

在CreativeCommonsAttribution下授权-ShareAlike未移植许可v3.0。

扫码关注腾讯云开发者

领取腾讯云代金券

http://www.vxiaotou.com