- May 8, 2005
- 415
- 0
- 76
I'm working in C and basically, I would like to use arrays of a stuct in another struct. example:
struct dum {
int a;
};
typedef struct dum dum;
struct hor {
dum *hordum;
};
typedef struct hor hor;
int main() {
hor *hd;
hd= (hor *) malloc(sizeof(hor));
hd->hordum=calloc(5,sizeof(dum));
(hd->hordum[0])->a=5;
(hd->hordum[1])->a=8;
}
This of course doen't work but hopefully you can the see the gist of what I'm trying to do. Is there an easy way to do this?
struct dum {
int a;
};
typedef struct dum dum;
struct hor {
dum *hordum;
};
typedef struct hor hor;
int main() {
hor *hd;
hd= (hor *) malloc(sizeof(hor));
hd->hordum=calloc(5,sizeof(dum));
(hd->hordum[0])->a=5;
(hd->hordum[1])->a=8;
}
This of course doen't work but hopefully you can the see the gist of what I'm trying to do. Is there an easy way to do this?
