Hello,
without being too much into C++: you allocate 'mol' on the stack, then push it
into the vector and clean it for re-usal afterwards.
Is that allowed? Does the vector atomagically make a copy of 'mol'? What
happens when you allocate 'mol' yourself and store the pointer to it in the
vector, like:
vector<OBMol*> molecules;
OBMol *mol;
while (!feof(f)) {
mol = new OBMol();
fscanf(f, "%c %c", &type, &comment);
if (type == comment)
continue;
//molecule title and its frequency
if (type == 't') {
fscanf(f, "%256s %d\n", buffer, &frequency );
mol->SetTitle(buffer);
}
//molecule nodes and edges
while (!feof(f)) {
fscanf(f, "%c", &type);
if (type == 'v' || type == 'V') {
fscanf(f, "%d %256s\n", &v1, buffer);
m->NewAtom(v1);
//set atom type
mol->GetAtomById(v1)->SetType(buffer);
}
else if (type == 'u' || type == 'U' ){
fscanf(f, "%d %d %d\n", &v1, &v2, &order);
mol->AddBond(v1+1, v2+1, order);
POS = ftell(f);
}
else if(type == 't') {
//go back one line to get new molecule header
fseek(f, POS, SEEK_SET);
molecules.push_back(mol);
break;
}
}
}
}
Does that change anything?
BTW: You declare 'mol' and then use 'm' afterwards in the code. If that really
compiles, you have a variable scope problem somewhere...
Best regards,
Ernst-Georg
------------------------------------------------------------------------------
Enable your software for Intel(R) Active Management Technology to meet the
growing manageability and security demands of your customers. Businesses
are taking advantage of Intel(R) vPro (TM) technology - will your software
be a part of the solution? Download the Intel(R) Manageability Checker
today! http://p.sf.net/sfu/intel-dev2devmar
_______________________________________________
OpenBabel-Devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbabel-devel