I was writing a C code to copy the contents of a Linked List onto another list. I want to know if there is a more efficient way of doing this.
Which is better?
Without going recursive, this is about the most compact you can get:
struct node *copy(struct node *org) { struct node *new=NULL,**tail = &new; for( ;org; org = org->link) { *tail = malloc (sizeof **tail ); (*tail)->info = org->info; (*tail)->link = NULL; tail = &(*tail)->link; } return new; }