Helo !!!
I was trying to implement linked list in which the data field is
Generic...
the structure details are..
typedef struct node
{
void *data;
struct node *next;
}gnode;
Now to add a node into it, and i have written this function.
void insert(gnode **head,void *data,unsigned int size)
{
gnode *temp;
int i=0;
temp=(gnode *)malloc(sizeof(gnode));
temp->data=malloc(size);
for(int i=0;i<size;i++)
*(char *)(temp->data+i) = *(char *)(data + i);
temp->next= (*head);
(*head)=temp;
}
Well i dont know how to copy the data into the temp->data.
But I m trying the following code...
for(int i=0;i<size;i++)
*(char *)(temp->data+i) = *(char *)(data + i);
But it is giving the error :sad:: ' void * ' : Unknown size .
If anyone knows any other way of copying it please tell me. And please
help me out in finding what is happening wrong in this code.
Thanks:-|