Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- struct link {
- char * name;
- struct link *next;
- };
- struct list{
- struct link *first;
- struct link *last;
- };
- struct list *list_new(){
- struct list *n = calloc(1, sizeof(struct list));
- return n;
- };
- struct list* copyList(struct list*list){
- struct list*new = list_new();
- struct link *current = list -> first;
- struct link *newCurrent = new -> first;
- struct link *p;
- if(current == NULL)
- return NULL;
- newCurrent = malloc(sizeof(struct link));
- newCurrent = p;
- while (current != NULL) {
- p ->shelfName = strdup((char*)current -> shelfName);
- p->next = malloc(sizeof(struct link));
- p = p->next;
- current = current->next;
- }
- return new;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement