[prev] [index] [next]

Dynamic Data Structures (cont)

Creating a new list through iteration
  • the right way

    NodeT *list, *head;
    head = makeNode(1);
    list = head;           // both point to the first node
    int i;
    for (i = 3; i < N; i += 2) {
    	list->next = makeNode(i);   // create and link new node  
    	list = list->next;          // move forward
    }
    printList(head);