You can open the file using the ios::ate flag (and ios::binary flag), so the tellg() function will directly give you directly the file size:
ifstream file( "example.txt", ios::binary | ios::ate);
return file.tellg();
You can open the file using the ios::ate flag (and ios::binary flag), so the tellg() function will directly give you directly the file size:
ifstream file( "example.txt", ios::binary | ios::ate);
return file.tellg();