found the function that fills the vector and it seems to be causing the problems. I use almost the same code as in this function within the program and that vector can be cleared without a problem. I've been looking at it for a while but can't pin point the problem. Could someone take a look at it, I must be missing something:
Code:
void ReadDataSec(FILE * inp, FSAD &Section , int nExpected)
{
char line[110];
int check;
int newline =0, endcount=0;
DataLine dl;
int size = nExpected*2 +1;
while ( fgets(line, sizeof line, inp) != NULL) // reads in a line of text from file
{
dl.Param = dl.Label=dl.SFactor=dl.SigBits=dl.Bit30=dl.Bit31=dl.Max=dl.Min = '\0';
newline =0;
if (strncmp(line, "\n", 1) == 0)
newline =1;
check = (sscanf(line, "%s %d %f %d %d %d %f %f", dl.Param, &dl.Label,
&dl.SFactor, &dl.SigBits, &dl.Bit30, &dl.Bit31, &dl.Max, &dl.Min));
if ( strncmp(dl.Param, "ENDL", 4) == 0 && newline ==0) // Exit if at the end of a section
{
dl.Label=dl.SFactor=dl.SigBits=dl.Bit30=dl.Bit31=dl.Max=dl.Min='\0';
Section.vectDL.push_back(dl);
break;
}
if ( strcmp(dl.Param, "END") == 0 && newline == 0) // set all fields to 0
at the end of subsection marker
{
dl.Label=dl.SFactor=dl.SigBits=dl.Bit30=dl.Bit31=dl.Max=dl.Min='\0';
Section.vectDL.push_back(dl);
endcount++;
}
if (strncmp(dl.Param, "END", 3) != 0 && newline ==0) // If the line is not
the end of subsection marker, copy the line into global vector
{
if (check == 8)
{
Section.vectDL.push_back(dl);
}
else if (check == 6)
{
dl.Max=dl.Min='\0';
Section.vectDL.push_back(dl);
}
}
}
if (endcount != nExpected)
EXIT_FAILURE;
}