80.8k views
3 votes
You want to read from a file, whose size you do not know. what can you do to ensure you read all the bytes of data within that file?

1 Answer

2 votes

While you cannot be sure you have enough memory to hold all the bytes of the file at the same time, you should read the bytes in chunks and discard them after processing. While reading, you keep testing for the end-of-file status.

User Arij SEDIRI
by
7.6k points