build link list for my program

July 20, 2009 at 04:29:41
Specs: Windows Vista
I have my code that i'm doing for a test to
submit in 3 hours I am stuck on the part wher I
have to use the link list: this the way it looks,
every thing is fine excep the part with the link
list:

while(!feof(input_file_for_patient))
{

temp_fill_patient_info_personnal(input_file_for_
patient,

patient_first_name,

patient_last_name,
&patient_id,

&patient_saving_balance,
index);


memory_allocation_for_patient_info(&SA_PATI
ENT,&SA_CLINIC,index );


fill_patient_info_personnal(patient_first_name,
patient_last_name,
&patient_id,

&patient_saving_balance,
&SA_PATIENT,
index);

add_patient_to_list(new_patient,
&SA_PATIENT);


index++;
buff++;
};

void add_patient_to_list(struct PATIENT_INFO
*new_patient,
struct PATIENT_INFO
*current_patient)
{

struct PATIENT_INFO *temp_patient =
NULL;


temp_patient = new_patient;

int restart=1, index=0;
while(restart)
{
switch(action_done())
{
case 1: printf("You are adding a node
to an empty list\n\n");
if(new_patient == NULL)
{
new_patient = current_patient;
}
else
{
printf("\aWRONG CHOICE,
YOUR NODE IS NOT EMPTY\n");
printf("@make another
choice\n@");
break;
}

// current_patient->first_name = ;
restart=0;
break;

case 2: printf("You are adding a node
as the new head of the list\n\n");
if( (new_patient == NULL) &&
(current_patient == NULL) )
{
printf("\aWRONG CHOICE,
YOUR NODE IS EMPTY\n");
printf("@make another
choice\n@");
break;
}

temp_patient = current_patient;

current_patient =
current_patient->next_patient;

restart=0;
break;

case 3: printf("You are adding a node
as the second node of the list\n\n");
if( (new_patient == NULL) &&
(temp_patient ==NULL))
{
printf("\aWRONG CHOICE,
YOUR NODE IS EMPTY\n");
printf("@make another
choice\n@");

new_patient->next_patient =
current_patient;
current_patient =
new_patient;

break;
}

// temp_patient->next_patient =
new_patient;
// new_patient->next_patient =
current_patient;


restart=0;
break;

case 4: printf("You are adding a node
somewhere else in the list\n\n");
if(new_patient == NULL)
{
printf("\aWRONG CHOICE,
YOUR NODE IS EMPTY\n");
printf("@make another
choice\n@");
break;
}

temp_patient = current_patient;

current_patient =
current_patient->next_patient;


restart=0;
break;


default:
printf("\a$$Your input is not
conform$$\n\n");
exit_now();
printf("\aprinting the menu and
restarting\n\n\n");
break;
}
}

}


See More: build link list for my program

Report •


#1
July 20, 2009 at 13:44:28
Try reposting in the Programming forum section.

Report •
Related Solutions


Ask Question