Skip to content

Std::istream

Methods

gcount

마지막 서식화 되지 않은 (unformatted) 입력 작업에서 읽어들인 문자의 개수를 리턴한다.

/* FILE: main.cpp, std::istream::gcount() test. */
#include <fstream>
#include <iostream>
#include <cstring>
using namespace std;

int main()
{
    char buf [11] = {0,};
    ifstream is("main.cpp");

    memset(buf, 0x00, sizeof(buf));
    is.read(buf, 10);
    cout << "READ: " << is.gcount() << ": " << buf << endl;

    memset(buf, 0x00, sizeof(buf));
    is.read(buf, 8);
    cout << "READ: " << is.gcount() << ": " << buf << endl;

    return 0;
}

Output:

READ: 10: /* FILE: m
READ: 8: ain.cpp,