I am scanning the contents of file and then performing some simple operations.
First i want to scan the file for a particular doctor name that works.
I have two records in the file but its not incrementing the counter to check patients which belong to that doctor and add up fees.
case 1:{
strcpy(doctor1,"Dr.Robert.Williams");
while(!feof(customer1) && Found==0)
{
fscanf(customer1,"%s %s %s %s %s %d %d %d %d",det.name,det.regis,det.pname,det.treatment,det.piont,&det.fees,&det.collect,&det.insure,&det.balance);
if(strcmp(doctor1,det.name)==0)
{
count++;
fees = det.fees + fees;
collected = det.collect + collected;
Found=1;
}
printf("\n\t\t NAME:%s",det.pname);
}
printf("\n\t\t DOCTORS NAME:%s",doctor1);
printf("\n\t\t NUMBER OF PATIENTS:%d",count);
printf("\n\t\t TREATMENT:%s",det.treatment);
printf("\n\t\t TOTAL FEE CHARGED:$ %d",fees);
printf("\n\t\t AMOUNT PAID:$ %d",det.collect);
printf("\n\t\t FEES COLLECTED:$ %d",collected);
}
break;
heres what the file looks like.
Dr.Robert.Williams 1 John.Grisam Cleaning 4/07/09 4500 3400 0 -1100
Dr.Robert.Williams 2 John.Whyte Cleaning 4/07/09 4500 3400 0 -1100