Archive for the ‘Uncategorized’ Category

Data size example of c++ file

July 31st, 2010 c# No comments

The following example uses the member functions we have just seen to obtain the size of a file:

// obtaining file size
using namespace std;

int main () {
long begin,end;
ifstream myfile (“example.txt”);
begin = myfile.tellg();
myfile.seekg (0, ios::end);
end = myfile.tellg();
cout << "size is: " << (end-begin) << " bytes.\n";
return 0;

size is: 40 bytes.

Categories: Uncategorized Tags: