Hey, I am currently following a code skeleton to implement the missing code for some function. Below is only some part of the implementation I've done so far. Yes it is not much yet...
I got stuck for the implementation of the list_add() function.
What I want to do there is to create a new node, and allocate some memory to it so I afterward can insert values to it. However I get compilation error. I have trial error it for awhile now without founding any solution. So I hoped for if someone know what error it is.
The error I get is
error: invalid conversion from `void*' to `my_list*'
#include <iostream>
using namespace std;
struct list_item
{
int key; // identifies the data
double value; // the data stored
struct list_item* next; // a pointer to the next data
};
struct my_list
{
struct list_item* first; // a pointer to the first element of the list
};
void list_init(struct my_list* my_this)
{
my_this = NULL;
}
void list_add(struct my_list* my_this, int key, double value)
{
my_list *new_node;
//allocate memory for next node
new_node = malloc(sizeof(my_list));
}
int main()
{
my_list a;
list_init(a);
return 0;
}