2012-10-23 94 views
2

一個非常簡單的錯誤,我想,但試圖編譯我的C代碼時,我得到這個錯誤:Ç遇到了問題(我認爲)

error: expected identifier before '(' token 

從這個代碼,我正在嘗試建立結構用鏈表的哈希表的哈希衝突:

typedef struct bN { 
    MEntry nestedEntry; 
    struct bN *next; 
} bucketNode; 

typedef struct bL { 
    bucketNode *first; 
    int bucketSize; 
} bucket; 

struct mlist { 
    bucket *currentTable; 
}; 

而且這個代碼,我其實初始化鏈表:

MList *ml_create(void){ 

    MList *temp; 

    if (ml_verbose){ 
     fprintf(stderr, "mlist: creating mailing list\n"); 
    } 
    if ((temp = (MList *)malloc(sizeof(MList))) != NULL){ 
     temp->currentTable = (bucket *)malloc(tableSize * sizeof(bucket)); 
     int i; 
     for(i = 0; i < tableSize; i++){ 
      temp->(currentTable+i)->first = NULL; /**ERROR HERE*/ 
      temp->(currentTable+i)->bucketSize = 0; /**ERROR HERE*/ 
     } 
    } 
    return temp; 

} 
+0

在這行是報告的錯誤? –

+0

對不起,不要以爲我的評論是非常明顯的。在第二塊代碼中,在for循環中大約3/4的下降:) –

+0

對不起,我沒有注意到它們 –

回答

6

您的語法關閉。你的意思是:

temp->currentTable[i].first = NULL; 
temp->currentTable[i].bucketSize = 0; 
0

變化

temp->(currentTable+i)->first = NULL; 

(temp->currentTable+i)->first = NULL;