我猜这是一个非常简单的错误,但在尝试编译我的 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;
}