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:
ios::ate
ios::binary
tellg()
ifstream file( "example.txt", ios::binary | ios::ate); return file.tellg();
2.1m questions
2.1m answers
60 comments
57.0k users