Advertisement
Guest User

Untitled

a guest
Jun 24th, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.46 KB | None | 0 0
  1.  void* listToArray(LinkedList* list, void* array)
  2.  {
  3.        int i;                                       /*Creates a variable i  to incremet with */
  4.        i=0;                                         /*Sets i = 0*/
  5.        list->current = list->head;                  /*Resets the current to the head of the list*/
  6.        while( list->current->next != NULL)                /* loops through the node while the next node isnt NULL*/
  7.        {
  8.                 GuideEntry* g;                                              /*Make new storage struct*/
  9.                 g = (GuideEntry*)malloc(sizeof(GuideEntry));               /*Dynamically allocate memory*/
  10.                 /*strcpy(g->nameStorage, (*(GuideEntry*)list->current->ptr)->nameStorage); */         /*Copy the name from the linked list into the struct*/
  11.                /* strcpy(g->timeStorage, (*(GuideEntry*)list->current->ptr)->timeStorage); */          /*Copy the time from the linked list into the struct*/      
  12.                 g = (GuideEntry*)(list->current->ptr);
  13.                 array[i] = g;                                                   /*stores the struct into the array*/
  14.             list->current = list->current->next;                                /*iterates the current node to the next one*/
  15.             i++;                                                            /*incremented the array*/
  16.             }
  17.            
  18.        return array;                                                      
  19.  }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement