> > I have the following structure
> > struct NetworkModel{
> > struct LayerModel{
> > struct NeuronModel{
> > long double *W;
> > long double Y;
> > long double V;
> > long double Delta;
> > long double Error;
> > long double Treshold;
> > }*N;
> > }*L;
> > }*nm;
> > Fairly simple :)
> > Each pointer type sub-element inside this structure is intended to
> > point an array of its king so I can use it like;
> > nm->L[a]->N[b]->W[c]=2;
> No you can't. After applying the subscripting operator you no longer
> have a pointer, so -> is inappropriate. What you can do is:
> nm->L[a].N[b].W[c] = 2;
> > To implement it I have the following idea which did not work
> > (something wrong fundemantally):
> > //I want to dynamically allocate the following NetworkModel
> > struct NetworkModel *ntw
> > //number of the LayerModel structures inside the NetworkModel to be x
> > ntw=(struct NetworkModel *)malloc(x*sizeof(struct LayerModel));
> > //and number of the NeuronModel structures inside the LayerModel to be
> > y
> > ntw.L=(struct LayerModel *)malloc(y*sizeof(struct NeuronModel));
> > //and finally I want 'W' inside the NeuronModel to be size of z
> > ntw.L.N=(struct NeuronModel *)malloc(z*sizeof(long double)+sizeof(long
> > double)*5);//here 5 is the rest of the doubles inside the NeuronModel
> You're assigning pointers to the wrong thing, and not initialising every
> member of the dynamic arrays. What you want is this:
> #include <stdlib.h>
> struct NetworkModel *ntw;
> int i, j;
> ntw = malloc(sizeof *nm);
> ntw->L = malloc(x * sizeof *ntw->L);
> for (i = 0; i < x; i++) {
> ntw->L[i].N = malloc(y * sizeof *ntw->L[i].N);
> for (j = 0; j < y; j++) {
> ntw->L[i].N[j].W = malloc(z * sizeof *ntw->L[i].N[j].W);
> }
> }
> - Kevin.