Oct
29
Obtaining File Size
ByThe 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; }
Leave a Comment
You must be logged in to post a comment.