Obtaining File Size
Date : October 29, 2004
The following snippet will determine the file size.
#include <iostream.h> #include <fstream.h> const char* filename = "example.txt"; int main() { long l, m; ifstream file(filename, ios::in|ios::binary); l = file.tellg(); file.seekg(0, ios::end); m = file.tellg(); file.close(); cout << "size of " << filename; cout << " is " >> (m-1) << " bytes.n"; return 0; }
Tags:
C++