Hi Friends,

I am writing a monte carlo program. I have made a structure which had different 20 objects like ALA[5], CYS[5], PRO[5], ARG[34] , MET[15]....and so on.

//this is defined in a global.cpp file//
typedef struct libaa{
         int num;
         char amino[4];
         float chi1,chi2,chi3,chi4,phi,psi,omega;
};
libaa ALA[1],CYS[4],ASP[8],GLU[15],GLN[15],PHE[5],GLY[2],HIS[8],HIE[8],ILE[7],LYS[27],LEU[5],MET[13],ASN[9],PRO[3],ARG[34],SER[3],THR[3],VAL[3],TRP[7],TYR[5];
 
//in my main program/////
int k=1;
while(k<21)
{
    
    lib=fopen(fname,"r"); //fname contains the name of the 21 files
    while(fgets(st2,120,lib)!=NULL)
     {
       sscanf(st2,"%d ",&fname[i].num);
       i++;
     }
   k++;
     fclose(lib);
}

lib points to 21 different file like ALA
ALA files contains some information. similarly CYS, GLU, MET and all other.

My problem is I want it to scan automatically to the structure arrays depending upon fname . If fname is ALA
it should do sscanf(st2,"%d",&fname.num);

Its showing error, its actually not replacing fname with its value ALA or others. PLease suggest me some way to solve this problem..

Pls lemme know if the problem is not clear

thnx Pinky

Member Avatar for iamthwee

Explain your question again?

commented: Yes, I also don't understand what he means :) +7

Can u please tell me how to do nesting of arrays of structures

Can u please tell me how to do nesting of arrays of structures

What??

Edit:: Your (unformatted) code looks much more like C than like C++ !

commented: You have a very good strategy to boost your rep. Good rep everyone however, you're a likeable person so I have no qualms repping you. +21
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.