i have an array, i want to create a doubly linked list from it,by transferring my elements to the nodes. and linking them through pointers(prev and next) what i did was
head = malloc(sizeof(struct)) head->prev=NULL head->next=NULL tail=head
for(i=0;i<num;i++){
//copy data from arr[i] to tail
temp=tail
tail->next=malloc(sizeof(struct))
tail=tail->next
tail->prev=temp
}
now, how do i copy the data? temp, head and tail are pointers to structure
memcpy, but it's hard to tell what your problem is. You only say what you want to do, but not why you fail at doing so. And again, the code you posted is not valid C, so it's either not exactly what you did, or that may be your problem because you can't compile.