I want to insert a string into struct data_node in a function called insert. My struct data_node is
struct data_node {
char name [25];
int data;
struct data_node *next;
};
and my insert function is:
struct data_node * insert (struct data_node **p_first, int elem, char *word ) {
struct data_node *new_node, *prev, *current;
current=*p_first;
while (current != NULL && elem > current->data) {
prev=current;
current=current->next;
} /* end while */
/* current now points to position *before* which we need to insert */
new_node = (struct data_node *) malloc(sizeof(struct data_node));
new_node->data=elem;
new_node->name=*word;
new_node->next=current;
if ( current == *p_first ) /* insert before 1st element */
*p_first=new_node;
else /* now insert before current */
prev->next=new_node;
/* end if current == *p_first */
return new_node;
};
when I compile , it says that the line 22 incompatible types when assigning to type 'char[25]' from type 'char' that means new_node->name=*word; is wrong. how could I solve this problem?