I've got a function which should malloc for a new node and then for space for a string in the data_item part of the node... but for the life of me I can't figure out why I get two errors... here is the function...
Code:void insert_at_front(char *n, node_ptr list) { node_ptr new_node = (node_ptr) malloc(sizeof(struct node)); new_node->data_item = (char *) malloc(sizeof(char) * strlen(n) + 1); strcpy(new_node->data_item, n); new_node->next = list->next; list->next = new_node; }
The two errors:
-second malloc line error is: assignment makes integer from pointer without a cast
-strcpy line error is: passing arg 1 of 'strcpy' makes pointer from integer without a cast
If anyone can give me any clues this would be greatly appreciated as I've spent a lot of the day trying to nut it out with no real insight beyond knowing it is a casting issue...