#include <fstream> std::ifstream::pos_type filesize(const char* filename) { std::ifstream in(filename, std::ifstream::ate | std::ifstream::binary); return in.tellg(); }
See http://www.cplusplus.com/doc/tutorial/files/ for more information on files in C++.
edit: this answer is not correct since tellg() does not necessarily return the right value. See http://stackoverflow.com/a/22986486/1835769
2.1m questions
2.1m answers
60 comments
57.0k users