[RESOLVED] File size in standard way
Hi all,
One of my application I used MFC(actually CFile) to find the file size in easy way.
Now I thought to do it using standard C++. Here is my try.
Code:
size_t file_size;
ifstream in_file;
in_file.open("C:\\temo_file.txt", ios_base::in);
if(in_file.is_open())
{
file_size = in_file.seekg(-1, ios_base::end).tellg();
cout << file_size;
}
My question is, this code gives misses one byte. Can you guys give me any reason for it.
Thanks
Re: File size in standard way
Why you have '-1'?
Code:
file_size = in_file.seekg(-1, ios_base::end).tellg();
Re: File size in standard way
ya, I got it. It should be 0. :)