I'm trying to implement a generic linked list. The struct for the node is as follows -
typedef struct node{
void *data;
node *next;
};
Now, when I try to assign an address to the data, suppose for example for an int, like -
int n1=6;
node *temp;
temp = (node*)malloc(sizeof(node));
temp->data=&n1;
How can I get the value of n1 from the node? If I say -
cout<<(*(temp->data));
I get -
`void*' is not a pointer-to-object type
Doesn't void pointer get typecasted to int pointer type when I assign an address of int to it?