Namespaces
Variants
Views
Actions

std::basic_filebuf::showmanyc

From cppreference.com
< cpp‎ | io‎ | basic filebuf
Revision as of 22:31, 2 November 2012 by P12bot (Talk | contribs)

protected:
virtual std::streamsize showmanyc()

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

Contents

Parameters

(none)

Return value

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

Notes

This function is optional. If not implemented, this function returns 0 (since the base class version std::basic_streambuf::showmanyc gets called)

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

Example

implementation test to see if showmanyc() is implemented for filebuf

#include <fstream>
#include <iostream>
 
struct mybuf : std::filebuf
{
     using std::filebuf::showmanyc;
};
 
int main()
{
    mybuf fin;
    fin.open("test.in", std::ios_base::in);
    std::cout << "showmanyc() returns " << fin.showmanyc() << '\n';
}

Output:

showmanyc() returns 6626

See also

Template:cpp/io/basic streambuf/dcl list in availTemplate:cpp/io/basic istream/dcl list readsome