I am using fstream to open and close a file. The code works OK, except the the file does not close when I close it the first time. I need to invoke close twice.
Any idea why?
And, what this is saying about my code that I do not realize??
The code:
fstream cif;
cif.open(INFO.c_str(), ios::in);
MYgetline(cif, cifline);// header
MYgetline(cif, cifline);; // pointer cif
Vector cifrule(countcommas(cifline)-1);
int comma=2;
for (int i=0; i<cifrule.length(); i++) cifrule(i)=comma_read(comma,cifline);
for (int c=0; c<cifrule.length(); c++)
{
Outcome(0,(cifrule(c)-1))=NewStatData(0,(cifrule(c)-1));
Outcome(1,(cifrule(c)-1))=NewStatData(1,(cifrule(c)-1));
Outcome(2,(cifrule(c)-1))=NewStatData(2,(cifrule(c)-1));
}
cif.close();
if (cif) cout << "cif open\n"; else cout << "cif closed\n";
cif.close();
if (cif) cout << "cif open\n"; else cout << "cif closed\n";
The output:
cif open
cif closed