I'm sure I've just missed this in the manual, but how do you determine the size of a file (in bytes) using C++'s istream
class from the fstream
header?
You can open the file using the ios::ate
flag (and ios::binary
flag), so the tellg()
function will give you directly the file size:
ifstream file( "example.txt", ios::binary | ios::ate); return file.tellg();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With