#include
#include
#include
#include "utlist.h" #define buflen typedef struct EL {char bname[buflen]; struct El *next, *prev;} El int namecmp (El *a, El *b) {return strcmp (a->bname,b->bname);} El *head = NULL; /* Important-initialize to null! */int main (int argc, char *argv[]) {El *name, *elt, *tmp, etmp; Char Linebuf[buflen]; int count; FILE *file; if (file = fopen ("Test11.dat", "r")) = = NULL) {perror ("can ' t Open:"); Exit (-1); } while (Fgets (linebuf,buflen,file) = null) {if ((name = (el*) malloc (sizeof)) = = null) exit (-1); strncpy (Name->bname,linebuf,buflen); Dl_append (head, name); } dl_sort (head, namecmp); Dl_foreach (Head,elt) printf ("%s", elt->bname); Dl_count (Head, ELT, COUNT); printf ("%d number of elements in list\n", count); memcpy (&etmp.bname, "wes\n", 5); Dl_search (HEAD,ELT,&ETMP,NAMECMP); if (ELT) printf ("Found%s\n", elt->bname); /* Now delete each elemeNT, use the safe iterator */Dl_foreach_safe (head,elt,tmp) {dl_delete (head,elt); } fclose (file); return 0;}