I’m using ifstream::read to read a file,
ifstream ifs("a.txt");
char buf[1024];
ifs.read(buf, 1024);
But a.txt’s size might be less than 1000 bytes, so how am I supposed to know how many bytes have been read from ifs?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can get the amount of characters extracted by the last operation with
std::ifstream::gcount:or
since
read(...)returns*this.