I've realised that my array of structs was being destroyd once the program finishes with the constructor. I've fixed that same way you did.
I think the problem comes from the way I pass it to a function. I'm writing a function to fill the array of structs. and I'm not sure how to pass the class to it correctly:
class FSAD //Fixed/Selectable Analog Data
int nExpected; // size = nExected*2+1
void MakeSec(DataLine *pDataSec)
pDataSec = new DataLine[nExpected*2+1];
If I don't use a function, and reference the array of stucts like this:
void ReadDataSec(FILE * inp, FSAD Section , int nExpected)
while ( fgets(line, sizeof line, inp) != NULL ) // reads in a line of text from file
//if ( strncmp(line, "ENDL", 4) == 0 ) // Exit if at the end of a section
sscanf(line, "%s", Section.pDataSec[i].Param);
printf("%s \n", Section.pDataSec[i].Param);
I get an run-time error that the memory could not be written.
strncpy(FAD.pDataSec.Param, "something", 20);