Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Please I need help on adding a node as the second node of the listand adding a n

ID: 3612943 • Letter: P

Question

Please I need help on adding a node as the second node of the listand adding a node somewhere else in the list and able to print itout. Below is my text file, I have 6 nodes in my text file

Pete Okay 45   345
Maud Okay 36 536
Caleb Dimitri 15 123
Cadrin Christopher 9 695
John Williams 12 542
James Evans 44 211


And below is the structure definition:
struct patient
{
       char firstname[20];
       char lastname[20];
       int age;
       int id;
       struct patient *link;
};
struct clinic
{
     char nameofclinic[30];
   struct patient *linklist;    
};
void patients(FILE *xfiles, struct patient *mems);
int main(void)
{
          FILE*file;
         struct clinicmembers;
struct patient *xpter       

       file openstatements..........
      
       patients(file, xpter);
       fclose(....);
}
void patients(FILE *xfiles, struct patient *mems)
{
        struct patient*pter;
        members->linklist =(struct patient *) malloc(1 * sizeof(struct patient);
          pter =(struct patient *) malloc(1 * sizeof(struct patient);
      fscanf(xfiles, "%s %s %d %d",members->linklist->firstname,members->linklist->lastname,&(members->linklist->age).........);

     fscanf(xfiles, "%s %s %d %d",pter->firstname, pter->lastname,&(pter->age).........);

      and I add a node to an empty listand add a node as the new head of the list like below
   BUT I DON'T KNOW WHAT TO DO AFTER THIS SOPLEASE HELP
      members->linklist->link = NULL;
       pter->link =members->linklist;
       members->linklist =pter;


help on adding a node as the second node of the list and adding anode somewhere else in the list and able to print it out.

Explanation / Answer

ascending? you mean sorted by the id field or something?