home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / listings / v_02_09 / 2n09016a < prev    next >
Text File  |  1991-07-31  |  706b  |  33 lines

  1.  
  2. /*
  3.  *  A C-style linked list structure definition
  4.  */
  5.  
  6. struct name_list_t {
  7.     char               name[61];
  8.     char               addr[101];
  9.     struct name_list_t *next;
  10.     struct name_list_t *prev;
  11. };
  12. struct name_list_t *name_top;  /* head of list */
  13. struct name_list_t *name_bot;  /* end of list */
  14.  
  15. /*
  16.  *  A code fragment that adds an entry to a linked list.
  17.  */
  18.  
  19. struct name_list_t *entry;
  20.  
  21. entry = (struct name_list_t *)malloc(sizeof(name_list_t));
  22. strcpy(entry->name, new_name);
  23. strcpy(entry->addr, new_addr);
  24. if (name_top = NULL)
  25.     name_top = entry;
  26. if (name_bot ! = NULL)
  27.     name_bot -> next = entry;
  28. entry->prev = name_bot;
  29. entry->next = NULL;
  30. name_bot = entry
  31.  
  32.  
  33.