我有以下结构:
struct hashItem {
char userid[8];
char name[30];
struct hashItem *next;
};
在下面的函数中,我使用一个 char 指针(char 数组)参数,希望将其赋值给结构体。
void insertItem(struct hashItem *htable[], char *userid, char *name)
{
int hcode = hashCode(userid);
struct hashItem *current = htable[hcode];
struct hashItem *newItem = (struct hashItem*) malloc(sizeof(struct hashItem));
newItem->userid = userid;
newItem->name = name;
[...]
}
然而我收到了以下错误信息:
hashtable.c: In function ‘insertItem’:
hashtable.c:62: error: incompatible types in assignment
hashtable.c:63: error: incompatible types in assignment
第62行和63行是“newItem->...”行。