i have following program to calculate size of file
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main(){
string line;
ifstream myfile ("C:\\Users\\7\\Desktop\\example\\text.txt",ios::in | ios::out |ios::binary);
if (!myfile){
cout<<"cannot open file";
exit (1);
}
while (!myfile.eof()){
getline(myfile,line);
cout<<line<<endl;
}
long l,m;
l=myfile.tellg();
myfile.seekg(0,ios::end);
m=myfile.tellg();
cout<<"size of text file is:";
cout<<(m-l)<<"bytes"<<endl;
myfile.close();
return 0;
}
for make more clarify in text.txt file i have wrote some copy of information from this site http://en.wikipedia.org/wiki/List_of_algorithms
but it shows me 0 bytes and why? what is wrong?