Gee*_*_SO 2 c arrays pointers compilation
我想这是一个简单的错误,但在尝试编译我的C代码时出现此错误:
error: expected identifier before '(' token
Run Code Online (Sandbox Code Playgroud)
从这段代码,我试图为哈希表设置一个哈希表的链接列表的结构:
typedef struct bN {
MEntry nestedEntry;
struct bN *next;
} bucketNode;
typedef struct bL {
bucketNode *first;
int bucketSize;
} bucket;
struct mlist {
bucket *currentTable;
};
Run Code Online (Sandbox Code Playgroud)
这个代码我实际初始化链表:
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;
}
Run Code Online (Sandbox Code Playgroud)
您的语法已关闭.你的意思是:
temp->currentTable[i].first = NULL;
temp->currentTable[i].bucketSize = 0;
Run Code Online (Sandbox Code Playgroud)