1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
|
// get file buffer size using in_avail
#include <iostream> // std::cout, std::streambuf, std::streamsize
#include <fstream> // std::ifstream
int main () {
std::ifstream ifs ("test.txt");
if (ifs.good()) {
std::streambuf* pbuf = ifs.rdbuf();
char c; ifs >> c;
std::streamsize size = pbuf->in_avail();
std::cout << "first character in file: " << c << '\n';
std::cout << size << " characters in buffer after it\n";
}
ifs.close();
return 0;
}
|