Hi there,
I'm trying to write a class that reads and writes INI files. One of my class's member function is
CINIKey::EnumSection(string& szBuffer, const int index) which just returns a string containing the
section name of a specific index in an INI file. The code I have is the following.

bool CINIKey::EnumSection(string& szBuffer,const int index)
{
for(int i=0;i<=index;i++)
{
szBuffer=ExtractSection();
nStartPos+=szBuffer.length();//Advance the position so it reads the next available section
}
if(szBuffer.size()==0) //No more section is left to extract
return false;
else
return true; //Still more sections left to be extracted

}




The call to ExtractSection() just extracts and returns a the string containing the section name specified by
nStartPos which is initially 0 so it searches for the first [section name] in the file. If I increase nStartPos
to after the first section's end bracket, then it will find the next section by finding another '['. Anyway,
I try to use the EnumSection like the following...


CINIKey key;
bool bResult;
int i;
for(i=0,bResult=true;bResult==true;i++)
{
bResult=key.EnumSection(value,i);
cout << value << endl;
}




That code is supposed to list all the section name in the INI file one by one and it actually works. The
problem is I also get the error message "abnormal program termination" at the end. It's also apprent that
the program terminates BEFORE my main returns anything! Please tell me what's wrong. Thanks.