在C中为struct指针赋值?

use*_*466 3 c struct pointers compiler-errors

我正在构建一个带有结构的链表字典,列表中的每个节点都定义如下:

typedef struct node node;
struct node
{                                                               
      int key;
      char value[ARRAY_MAX];
      node *next;
};  
Run Code Online (Sandbox Code Playgroud)

我遇到问题的地方是我在insert和makedict函数中为key或value赋值.我在分配时收到以下错误:

node* insert(node* start, char* vinput, int kinput) {
    node* temp = start;
    while((temp->next->key < kinput) && temp->next!=NULL) {
        temp=temp->next;
    }
    if(temp->key==kinput) {
        temp->key = kinput;
        return temp;
    } else {
        node* inputnode = (node*)malloc(sizeof(node));
        inputnode->next = temp->next;
        temp->next = inputnode;
        inputnode->key = kinput;   /*error: incompatible types in assignment*/
        inputnode->value = vinput;
        return inputnode;
}
Run Code Online (Sandbox Code Playgroud)

和:

node* makedict(char* vinput, int kinput) {
    node* temp = (node*)malloc(sizeof(node));
    temp->value = vinput;
    temp->key = kinput; /*error: incompatible types in assignment*/
    temp->next = NULL;
    return temp;
}
Run Code Online (Sandbox Code Playgroud)

我知道我可能错过了一些非常明显的东西,但我一直在读这段代码而无济于事.任何帮助表示赞赏.

Cha*_*rns 7

我觉得行

inputnode->value = vinput;
Run Code Online (Sandbox Code Playgroud)

是编译器抱怨的.尝试

strcpy(inputnode->value, vinput);
Run Code Online (Sandbox Code Playgroud)

或者,更好的是,将'value'字段设为char*并执行

inputnode->value = strdup(vinput)
Run Code Online (Sandbox Code Playgroud)