名稱空間
變體
操作

std::basic_filebuf<CharT,Traits>::showmanyc

來自 cppreference.com
< cpp‎ | io‎ | basic filebuf
 
 
 
 
protected:
virtual std::streamsize showmanyc()
(可選)

如果已實現,則返回檔案中剩餘可讀取的字元數。

目錄

[編輯] 返回值

檔案中可供讀取的字元數,如果已到達檔案末尾則返回 -1

[編輯] 注意

此函式是可選的。如果未實現,則此函式返回 0(因為呼叫了基類版本 std::basic_streambuf::showmanyc)。

無論是否實現,如果獲取區為空,此函式通常由 std::basic_streambuf::in_avail 呼叫。

此函式的名稱代表“stream: how many characters?”(流:有多少字元?),因此它發音為“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> 的公有成員函式) [編輯]