P
P
Pinkman2021-12-12 20:39:41
C++ / C#
Pinkman, 2021-12-12 20:39:41

How to find out how many bytes std::ifstream.read() has read?

Good evening! How to find out how many bytes the read method has read?

while (!file.eof())
  {
    char* tmp = new char [BUFSIZE];
    file.read(tmp, BUFSIZE);
    buf.addData(tmp, BUFSIZE);
  }

I need to send as many bytes to the buffer as it was read, but the read method does not return the number of bytes. If there is some similar method (except for the read function ) or a method that will allow you to find out how many bytes have been read by read ?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
W
Wataru, 2021-12-12
@famousman204

Well, look at the documentation .
It says in English and white:

The number of characters successfully read and stored by this function can be accessed by calling member gcount.

There is even an example below.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question