Code:#include<stdio.h> #include<stdlib.h> struct list1{ char *name; struct list1 *next; }; struct list1* freemem1(struct list1 **node) { struct list1 *temp; temp=*node; if(temp==NULL) { temp=temp->next; free(*node); } return temp; } void addname(char name[],struct list1 **node) { struct list1 *x,*ptr; char *s = malloc( sizeof( name ) ); x = malloc(sizeof(struct list1)); strcpy( s, name); x->name=s; x->next=NULL; ptr=*node; if(*node==NULL) *node=x; else{ while(ptr->next!=NULL) ptr=ptr->next; ptr->next=x; } } int main(void) { struct list1 *nList,*ptr; FILE *fileptr; char name[BUFSIZ],dump; nList= NULL; fileptr=fopen("namelist.txt","r"); if(fileptr==NULL) perror("Unable to open file"); else{ while(fscanf(fileptr,"%[^\n]\n",name,&dump)!=EOF) { printf("%s\n",name); addname(name,&nList); } for(ptr=nList;ptr;ptr=freemem1(&ptr)) { printf("%s\n", ptr->name); } } return 0; }