
April 14th, 2003, 10:45 AM
|
|
Junior Member
|
|
Join Date: Apr 2003
Posts: 4
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
double pointer to a structure within a structure
i've been latly working on some project (neverminde the details), and i got stuck in this part....
there are two structures involved in this problem:
struct folder {
char name[20];
struct file **files;
struct folder *subfolder;
};
struct file {
char name[20];
char *info;
};
now the problem comes when i'm trying to do this:
int main () {
struct folder home =
{"home", (struct file *) calloc(2, sizeof(struct file)), NULL};
home.files[0] = {"test.txt" , NULL}; /* problem */
}
EOF
so the problem comes is the line i have marked with a comment. anyways, i'm trying to insert some values into one of the dynamicly allocated structures. but the compile says:
prase error before '{'
what have i done wrong? bah i guess i'll find my own mistake before i get an answer :\
BTW, this program runs under linux. gcc compiler.
|