Movatterモバイル変換


[0]ホーム

URL:


cppreference.com
Namespaces
Variants
    Actions

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

      From cppreference.com
      <cpp‎ |io‎ |basic filebuf
       
       
       
       
      protected:
      virtualstd::streamsize showmanyc()
      (optional)

      If implemented, returns the number of characters left to read from the file.

      Contents

      [edit]Return value

      The number of characters available for reading from the file, or-1 if the end of file was reached.

      [edit]Notes

      This function is optional. If not implemented, this function returns0 (since the base class versionstd::basic_streambuf::showmanyc gets called).

      Whether implemented or not, this function is normally called bystd::basic_streambuf::in_avail if the get area is empty.

      The name of this function stands for “stream: how manycharacters?”, so it is pronounced “S how manyC", rather than “show many C”.

      [edit]Example

      An implementation test to see ifshowmanyc() is implemented forstd::filebuf.

      Run this code
      #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';}

      Possible output:

      showmanyc() returns 254

      [edit]See also

      obtains the number of characters immediately available in the get area
      (public member function ofstd::basic_streambuf<CharT,Traits>)[edit]
      extracts already available blocks of characters
      (public member function ofstd::basic_istream<CharT,Traits>)[edit]
      Retrieved from "https://en.cppreference.com/mwiki/index.php?title=cpp/io/basic_filebuf/showmanyc&oldid=181821"

      [8]ページ先頭

      ©2009-2025 Movatter.jp