char buf[25];
ifstream fin("test.txt", ifstream::binary);
while (!fin.eof()) {
bzero(buf, sizeof(buf));
fin.read(buf, sizeof(buf));
}
The file test.txt contains 75 characters, no newlines or any other special character. Given the code, the while loop should only iterate 3 times, but it ends up iterating 4 times. During the last iteration, nothing is being stored in the buf variable. Why is this happening?