I sort of cringe at the sight of extensive file operation in code. But good old freopen()
has failed me in this particular code segment-
int main()
{
ifstream fin;
int next=0;
fin.open("In.txt");
if(fin.is_open())
{
while(!fin.eof())
{
cout<<next;
next++;
}
}
else cout<<"Unable to open file"<<endl;
return 0;
}
The headers I included are iostream, fstream and cstdio. This goes into an infinite loop.
My question is, the file I gave as input definitely has an end. But why doesn't the program terminate? Thanks in advance.