2014-01-14 71 views
0

我的結構是這樣的:指定地點

struct Node 
{ 
    int value; 
    struct Node *children[26]; 
}; 

typedef struct Node *List; 

我想配第一(主)結構變量(或指針),所以我會回來給它(在移動到'substructs'後)。即

start = malloc(sizeof(struct Node)); 
(this variable) = start; 
list = (this variable); 
list = list -> children[25]; 
... 
list = (this variable) //We're again in main/first struct. 
+1

問題是,一旦你改變了'list'指向原來的'list-> children [25]',你就失去了對原始的引用。如果你有'temp = list;'然後'temp = list-> children [25];'等等,你保留原始引用。 –

回答

1

所以......。你爲什麼不能說:

List start = malloc(whatever); 
List list = start; 
list = list->children[25]; // index 26 is out of bounds… 

問題是你不確定你可以聲明一些類型的List?